Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with dynamic drop down  RSS feed

 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 panel grids, where in the first panel grip I'm using a4j:commandButton to populate the drop down selectmenu in the panel grid 2. When I submit the panelgrid2, the drop down selectmenu is not sending any values back to the managed bean. Below is my code snippet.

<h:panelGrid>
.........
<a4j:commandButton action="#{action.GetList}" value="Get List" reRender="list"/>
</h:panelGrid>

<h:panelGrid id ="2">
<h:selectOneMenu value="#{action.selectList}" id="list" rendered="true">
<f:selectItems value="#{coreServices.selectLists}" />
</h:selectOneMenu>

<h:commandButton action="#{coreServices.Indexes}" value="Show Indexes" />
</h:panelGrid>

Managed Bean code....

private List<SelectItem> selectLists; // both get/set method implemented.
private String selectRepository;

for (ArrayList uList : obj)
{
selectLists(new SelectItem((String)uList.getId(), uList.getName());
}

Can anyone tell me what I'm missing. When the values are populated in dropdown from a4j:commandButton in the panelGrid2 and If I do a view source on the browser, I don't see any values listed for the drop down.
 
sathish Tl
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put h:selectOneMenu inside <a4j:region>
 
Karanjit Singh
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can also place your h:selectOneMenu inside <a4jutputpanel ajaxrendered=true> as follows:

<a4jutputpanel ajaxrendered=true>
Your Code...(h:selectOneMenu)
</a4jutputpanel>
 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still getting
java.util.NoSuchElementException
javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:118)
javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:144)
javax.faces.component.UISelectOne.matchValue(UISelectOne.java:161)

What I tried was, In the
<h:panelGrid id="1">
.....
<a4j:commandButton action="#{action.GetList}" value="Get List" reRender="list"/>
.....
</h:panelGrid>
Now once I click on "Get List" button, I do see values in the drop down of panelGrid 2 is getting populated.
<h:panelGrid id ="2">
<a4jutputPanel ajaxRendered="true">
<h:selectOneMenu value="#{action.selectList}" id="list" rendered="true">
<f:selectItems value="#{coreServices.selectLists}" />
</h:selectOneMenu>
</a4jutputPanel>
</h:panelGrid>
As you suggested I added <a4jutputpanel> tags around the h:selectOneMenu like above. Trying to submit the panelGrid 2 is throwing me the exception.
 
Karanjit Singh
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srinivas

Can I have your java code, which you have written to populate the drop down list. I think that is creating some problem.

Regards

Karanjeet Singh
 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karanjeet,
You are right, I had a problem in my java code. The scope of the object is getting lost. Once I let the scope to session level it started working. Thank you very much for pointing me in right direction.

Regards,
 
Karanjit Singh
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem Srinivas.

Good Luck!

Regards
Karanjeet Singh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!