NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Don Quixote
Joined: 31 Dec 2010 Posts: 5
|
Posted: Tue Jan 04, 2011 1:55 am Post subject: ELException creating 2 dependable selectOneMenus with native AJAX of JSF in NetBeans 6.9.1 |
|
|
Hello people. I've already posted this topic in the Java EE users forum, but since there are almost 200 views and none replies, i suppose i posted on the wrong forum, that's why i'm posting here... correct me if i'm wrong.
I'm new in this forum, and i was wondering if you could help me solve this urgent problem.
Getting to the point. I'm using NetBeans 6.9.1 with JSF 2.0, generating the CRUD from the DB.
I have 3 entities: Country, City and Street. What i want is that, in Create.xhtml for Street, it displays 2 SelectOneMenus, for Country and City, and one InputText for Street. So that, choosing a Country, via the NATIVE AJAX of JSF, the SelectOneMenu for City be fulfilled, without refreshing the entire page.
As the title refers, i've done something using NetBeans 6.9.1, and it gives and ELException.
I'll show you the code of Create.xhtml for entity Street, StreetController and CityFacade( which contains the method that returns all cities from a determined country ).
Create.xhtml
| Code: |
...
<h:selectOneMenu id="country" [color=red]value="#{streetController.idCountry"[/color] title="#{bundle.CreateStreetTitle_country}" required="true" requiredMessage="#{bundle.CreateStreetRequiredMessage_country}">
<f:selectItems value="#{countryController.itemsAvailableSelectOne}"/>
<f:ajax execute="@this" immediate="true" render="city"/>
</h:selectOneMenu>
<h:selectOneMenu id="city" value="#{streetController.selected.city}" title="#{bundle.CreateStreetTitle_city}" required="true" requiredMessage="#{bundle.CreateStreetRequiredMessage_city}">
<f:selectItems value="#{streetController.citiesFromCountry}"/>
</h:selectOneMenu>
...
|
The code in red is what generates the exception. I've done like this, but i'm not sure that this is right. If it doens't turn red, well, it's the code between [color=red]...[color]
StreetController
| Code: |
...
@EJB private session.StreetFacade ejbFacade;
@EJB private session.CityFacade cityFacade;
private int idCountry;
public SelectItem[] getCitiesFromCountry()
{
List<City> list = cityFacade.allCitiesFromCountry( idCountry );
return JsfUtil.getSelectItems(list, true);
}
public void setIdCountry( int idCountry )
{ this.idCountry = idCountry ; }
public int getIdCountry()
{
return idCountry;
}
...
|
CityFacade
| Code: |
...
private EntityManager em;
public List<City> allCitiesFromCountry( int idCountry )
{
Query q = em.createQuery( "select c from City c where c.id_country = :idCountry" );
q.setParameter( "idCountry", idConutry);
return q.getResultList();
}
...
|
I'll hopelly wait for an answer.
THANK YOU |
|
| Back to top |
|
 |
Petr Jiricka Posted via mailing list.
|
Posted: Wed Jan 05, 2011 10:11 am Post subject: Re: ELException creating 2 dependable selectOneMenus with native AJAX of JSF in NetBeans 6.9.1 |
|
|
Hi, can you share more details about the exception? You should be able to report it directly from the IDE, can you please do that (if you haven't yet)?
Also, several problems in this area were recently fixed in NetBeans 7 builds, can you please try the latest build from here?
http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/
Thanks,
Petr
On Jan 4, 2011, at 2:56 AM, Don Quixote wrote:
| Quote: | Hello people. I've already posted this topic in the Java EE users forum, but since there are almost 200 views and none replies, i suppose i posted on the wrong forum, that's why i'm posting here... correct me if i'm wrong.
I'm new in this forum, and i was wondering if you could help me solve this urgent problem.
Getting to the point. I'm using NetBeans 6.9.1 with JSF 2.0, generating the CRUD from the DB.
I have 3 entities: Country, City and Street. What i want is that, in Create.xhtml for Street, it displays 2 SelectOneMenus, for Country and City, and one InputText for Street. So that, choosing a Country, via the NATIVE AJAX of JSF, the SelectOneMenu for City be fulfilled, without refreshing the entire page.
As the title refers, i've done something using NetBeans 6.9.1, and it gives and ELException.
I'll show you the code of Create.xhtml for entity Street, StreetController and CityFacade( which contains the method that returns all cities from a determined country ).
Create.xhtml
Code:
...
<h:selectOneMenu id="country" value="#{streetController.idCountry" title="#{bundle.CreateStreetTitle_country}" required="true" requiredMessage="#{bundle.CreateStreetRequiredMessage_country}">
<f:selectItems value="#{countryController.itemsAvailableSelectOne}"/>
<f:ajax execute="@this" immediate="true" render="city"/>
</h:selectOneMenu>
<h:selectOneMenu id="city" value="#{streetController.selected.city}" title="#{bundle.CreateStreetTitle_city}" required="true" requiredMessage="#{bundle.CreateStreetRequiredMessage_city}">
<f:selectItems value="#{streetController.citiesFromCountry}"/>
</h:selectOneMenu>
...
The code in red is what generates the exception. I've done like this, but i'm not sure that this is right. If it doens't turn red, well, it's the code between [color=red]...[color]
StreetController
Code:
...
@EJB private session.StreetFacade ejbFacade;
@EJB private session.CityFacade cityFacade;
private int idCountry;
public SelectItem[] getCitiesFromCountry()
{
List<City> list = cityFacade.allCitiesFromCountry( idCountry );
return JsfUtil.getSelectItems(list, true);
}
public void setIdCountry( int idCountry )
{ this.idCountry = idCountry ; }
public int getIdCountry()
{
return idCountry;
}
...
CityFacade
Code:
...
private EntityManager em;
public List<City> allCitiesFromCountry( int idCountry )
{
Query q = em.createQuery( "select c from City c where c.id_country = :idCountry" );
q.setParameter( "idCountry", idConutry);
return q.getResultList();
}
...
I'll hopelly wait for an answer.
THANK YOU
|
|
|
| Back to top |
|
 |
Don Quixote
Joined: 31 Dec 2010 Posts: 5
|
Posted: Wed Mar 16, 2011 2:48 pm Post subject: |
|
|
| I got the error. Thanks Petr. |
|
| Back to top |
|
 |
angie_hz
Joined: 12 May 2011 Posts: 3
|
Posted: Thu May 12, 2011 9:30 am Post subject: |
|
|
Help please.
I have a similar problem, but with 4 entities: pais, comunidad, provincia, ciudad.
I can read all values from the database tables associated to these entities, but I'm unable to pass the id_pais value to the corresponding method of comunidadController.java. This is the code of create.xhtml:
<h:selectOneMenu id="someSelect" value="#{hpaisController.idpais}" required="true">
País: <f:selectItems value="#{hpaisController.itemsAvailableSelectOne}"/>
<f:ajax execute="@this" render="comunidad"/>
</h:selectOneMenu>
<h:selectOneMenu id="comunidad" value="#{hcomunidadController.selected.id}" required="true" >
Comunidad <f:selectItems value="#{hpaisController.comunidadesFromPaises}"/>
</h:selectOneMenu>
The method "getComunidadesFromPaises()" is like your method "getCitiesFromCountry()" and the query where you have to select the idpais for the comunidades list is like your query in CityFacade.
I appreciate any help.
Thanks.
Angie. |
|
| Back to top |
|
 |
Manfred Riem Posted via mailing list.
|
Posted: Thu May 12, 2011 11:42 pm Post subject: Re: ELException creating 2 dependable selectOneMenus with native AJAX of JSF in NetBeans 6.9.1 |
|
|
What version of JSF are you running?
-----Original Message-----
From: angie_hz [mailto:address-removed]
Sent: Thursday, May 12, 2011 3:31 AM
To: address-removed
Subject: [nbajax] ELException creating 2 dependable selectOneMenus with
native AJAX of JSF in NetBeans 6.9.1
Help please.
I have a similar problem, but with 4 entities: pais, comunidad, provincia,
ciudad.
I can read all values from the database tables associated to these entities,
but I'm unable to pass the id_pais value to the corresponding method of
comunidadController.java. This is the code of create.xhtml:
<h:selectOneMenu id="someSelect" value="#{hpaisController.idpais}"
required="true">
País: <f:selectItems
value="#{hpaisController.itemsAvailableSelectOne}"/>
<f:ajax execute="@this" render="comunidad"/>
</h:selectOneMenu>
<h:selectOneMenu id="comunidad" value="#{hcomunidadController.selected.id}"
required="true" >
Comunidad <f:selectItems
value="#{hpaisController.comunidadesFromPaises}"/>
</h:selectOneMenu>
The method "getComunidadesFromPaises()" is like your method
"getCitiesFromCountry()" and the query where you have to select the idpais
for the comunidades list is like your query in CityFacade.
I appreciate any help.
Thanks.
Angie.
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1375 / Virus Database: 1500/3633 - Release Date: 05/12/11 |
|
| Back to top |
|
 |
Petr Jiricka Posted via mailing list.
|
Posted: Fri May 13, 2011 9:08 am Post subject: Re: ELException creating 2 dependable selectOneMenus with native AJAX of JSF in NetBeans 6.9.1 |
|
|
Hi Angie,
as I already wrote to the previous user, have you tried how this works in NetBeans 7.0?
Petr
On May 12, 2011, at 11:30 AM, angie_hz wrote:
| Quote: | Help please.
I have a similar problem, but with 4 entities: pais, comunidad, provincia, ciudad.
I can read all values from the database tables associated to these entities, but I'm unable to pass the id_pais value to the corresponding method of comunidadController.java. This is the code of create.xhtml:
<h:selectOneMenu id="someSelect" value="#{hpaisController.idpais}" required="true">
Pa |
|
| Back to top |
|
 |
angie_hz
Joined: 12 May 2011 Posts: 3
|
Posted: Fri May 13, 2011 10:59 am Post subject: |
|
|
Thanks Petr, I tried in NetBeans 7.0, but it doesn't work.
I got the same results.
Angie.
P.D. I'm using JSF 2.0 |
|
| Back to top |
|
 |
angie_hz
Joined: 12 May 2011 Posts: 3
|
Posted: Fri May 13, 2011 11:38 am Post subject: Re: ELException creating 2 dependable selectOneMenus with native AJAX of JSF in NetBeans 6.9.1 |
|
|
| dd |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|