Skip to main content

JSF: f:ajax "execute" not working properly when adding "render" targeting another "selectOneMenu"

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
JeanMeurtrier
Offline
Joined: 2011-09-09

Hello Glassfish users,
Mentally replace [] by <>, because tags are interpreted in the forum.
This code is working fine, i.e. setCurrentComponent() is called when an item is selected:
[h:body]
[h:form]
[h:selectOneMenu value="#{monitoringAdministrationController.currentComponent}"]
[f:ajax event="change" execute="@this"/]
[f:selectItems value="#{monitoringAdministrationController.componentNames}"/]
[/h:selectOneMenu]
[/h:form]
[/h:body]
Now I want a second menu content to be updated when an item is selected in the first one. But when I add the render attribute with the ID of the second menu, setCurrentComponent() is not called anymore!

[h:body]
[h:form]
[h:selectOneMenu value="#{monitoringAdministrationController.currentComponent}"]
[f:ajax event="change" execute="@this" render="modelList"/]
[f:selectItems value="#{monitoringAdministrationController.componentNames}"/]
[/h:selectOneMenu]
[h:selectOneMenu id="modelList" value="#{monitoringAdministrationController.currentModel}"]
[f:selectItems value="#{monitoringAdministrationController.modelNames}"/]
[/h:selectOneMenu]
[/h:form]
[/h:body]
And if I take the second menu out of the form, the modelList ID is not found (even if ID's are DOM scoped):
[h:body]
[h:form]
[h:selectOneMenu value="#{monitoringAdministrationController.currentComponent}"]
[f:ajax event="change" execute="@this" render="modelList"/]
[f:selectItems value="#{monitoringAdministrationController.componentNames}"/]
[/h:selectOneMenu]
[/h:form]

[h:selectOneMenu id="modelList" value="#{monitoringAdministrationController.currentModel}"]
[f:selectItems value="#{monitoringAdministrationController.modelNames}"/]
[/h:selectOneMenu]
[/h:body]

Does someone have an explanation concerning this strange behaviour?
Thanks a lot!

JM

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JeanMeurtrier
Offline
Joined: 2011-09-09

Sorry, the spaces between the lines have completely changed once the message has been posted...

JM

JeanMeurtrier
Offline
Joined: 2011-09-09

Hello all,

I have solved my problem. My "currentComponent" that is the value of the "selectOneMenu" was not set to an existing value of the list. I was aware it may be a problem but I didn't suspect it was indirectly the source of this strange behaviour. I don't still understand why it works with only one selectOneMenu but not with two. Even if I'm not blocked anymore, I remain interested in an explanation. ;-)

Regards,

JM