Reputation: 6979
In the JSF code, I see this:
...
<h:selectOneMenu id="clientCode" value="#{theBean.clientCodeSelection}">
<f:selectItem itemValue="" itemLabel="Please select one" />
<f:selectItems value="#{theBean.clientList}" />
<f:ajax render="go"/>
</h:selectOneMenu>
...
<h:commandButton id="go" value="Go" immediate="true" >
<f:ajax render="clientTable" event="click" listener="#{theBean.doSearch}"></f:ajax>
</h:commandButton>
May I know what does <f:ajax render="go"/>
actually do? My initial assumption is to render the Go button, but I don't think it is as strict forward as I think. Please correct me if I am wrong.
Upvotes: 0
Views: 6436
Reputation: 1108567
The <f:ajax render="go">
will update the generated HTML representation of the JSF component with relative client ID go
when the ajax request has completed successfully in the webbrowser. Basically, the JSF component with relative client ID go
will be located in the JSF component tree in the webserver and then executed, whereafter its generated HTML output will end up in the ajax response. Once the ajax response returns in the webbrowser, exactly this HTML output will be updated in the HTML DOM tree in the webbrowser. This is very useful if the JSF component can generate different HTML content on a per-request basis based on the submitted form data.
Note that this only works if the JSF component is always rendered (i.e. it doesn't have a rendered="false"
on itself or its parents).
In your particular example, there's basically nothing in the generated HTML representation which could change on a per-request basis. So that <f:ajax render="go">
is in this specific case seemingly completely useless. If you would for example have a second dropdown whose list of available items depends on the selected item of the current dropdown, then it would make sense to reference it in <f:ajax render>
, so that it get updated with new items when you change the current dropdown.
Upvotes: 3
Reputation: 187
Here it does nothing but in case you want to display commandButton on some rendering condition then it will be used...
Upvotes: 0