I have a <rich:popupPanel>
tag and inside of it I use <f:ajax>
events. Therefore the <rich:popupMenu>
also needs to have a <h:from>
inside of it. In my ajax event I need to grab a value form the 'main page' therefore I list it in the execute list with the corresponding :formid:elementid pattern but this doesn't work - the value is null in the listener method. here is the code:
<h:form id="form">
...
<h:selectOneMenu id="selectUser" value="#{usersBean.user_id}" styleClass="comboBoxes" >
<f:selectItems value="#{usersBean.myModelUsersValues}" />
<a4j:ajax event="valueChange" listener="#{usersBean.userSelected}" render="login password customer_name" execute="@this"/>
</h:selectOneMenu >
...
</h:form>
<rich:popupPanel id="popup" modal="true" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Atributes" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('popup')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<h:form id="popupForm">
...
<h:selectOneListbox id="atrib_list" value="#{usersBean.atribSelect}" styleClass="comboBoxes" style="height:100px;width:100px;">
<f:selectItems value="#{usersBean.atribValues}" />
<f:ajax event="valueChange" listener="#{usersBean.atribValuesChanged}" render="child_list" execute="@this :form:selectUser"/>
</h:selectOneListbox >
...
</h:form>
</rich:popupPanel>
In the usersBean.atribValuesChanged
listener method the usersBean.user_id
field is empty (not having the value that was selected). How can I force to execute the form:selectUser element so that I can read it's selected value in my listener method?
Part2:
This is just a btw. question, maybe I should open another thread for this. The problem is that when the <h:selectOneListBox>
has only one value it is created more like a h:selectOneMenu
. This looks bad and also the valueChange
event is not fired when you select it. This problem does not exist in <h:selectManyListBox>
is it a bug? Is it fixable?
That's expected behaviour, you really can't submit any data outside the form.
You can rerender JSF components outside the form (see this article), but you can't send anything outside the form to the server.
So, maybe what you want to do is to place an h:inputHidden
inside the form you want to send, rerendering it in the h:selectOneMenu
from the first form, and then send the idUserHidden
on the form:
<h:form id="form">
...
<h:selectOneMenu id="selectUser" value="#{usersBean.user_id}"
styleClass="comboBoxes" >
<f:selectItems value="#{usersBean.myModelUsersValues}" />
<!-- rerender the hidden input also: -->
<a4j:ajax event="valueChange" listener="#{usersBean.userSelected}"
render="login password customer_name :idUserHidden" execute="@this"/>
</h:selectOneMenu >
...
</h:form>
....
<h:form>
....
<!-- hidden input to submit the same value of :selectUser -->
<h:inputHidden id="idUserHidden" value="#{usersBean.user_id}" />
<h:selectOneListbox id="atrib_list" value="#{usersBean.atribSelect}"
styleClass="comboBoxes" style="height:100px;width:100px;">
<f:selectItems value="#{usersBean.atribValues}" />
<f:ajax event="valueChange" listener="#{usersBean.atribValuesChanged}"
render="child_list" execute="@this idUserHidden"/>
</h:selectOneListbox >
</h:form>