• Post Reply Bookmark Topic Watch Topic
  • New Topic

HtmlSelectOneListBox value not set  RSS feed

 
Domingo Castellar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I tried to read a value from an HtmlSelectOne and I could not get.

The jsp is build programmatically and this is the code of the class that generate the html code:

HtmlSelectOneListbox combo = (HtmlSelectOneListbox) panel.getChildren().get(2);
String bind = "#{comboAction.name}";
combo.setValueBinding("value", context.getApplication().createValueBinding(bind));

UISelectItems items = new UISelectItems();

//get the list of values

ArrayList arr = new ArrayList();
for (int i = 0; i < lista.size(); i++) {
arr.add(new SelectItem(list.getId(),list.getName());
}

items.setValue(arr);
combo.getChildren().add(items);

and in the same class I have the variable "name" and the method get and set of this.

in faces-config.xml I define:
<managed-bean>
<managed-bean-name>comboAction</managed-bean-name>
<managed-bean-class>com.view.action.ComboAction</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>


but I can't get the value of the bean when I push a button that is bind to another method of this class.


How can I get the value of the select??
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite sure if I understand your prooblem, but your bean is in request scope, so it will be requested on every submit
 
Domingo Castellar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's in the request, but the problem is that I can't get the value in any submit.

If I put the next code in the same jsp:

<t:selectOneListbox id="hola" value="#{comboAction.name}" size="1">
</t:selectOneListbox>


The set method in the bean is call correctly, with a correct value. The problem is I need to dynamically build the jsp, but the code does not work (despite apparently equal to the static).

¿Why this behavior? ¿Any solutions?
 
Domingo Castellar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally the problem was a stupid property set in the original component.
The component that was recovered from the context had set to "True" the readonly property , and that was the problem.

As you can see a stupid problem, because the code posted was correct.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!