This content has been marked as final.
Show 4 replies
-
1. Re: Inversion of re-render (subscription based re-rendering)
luxspes Apr 18, 2009 11:38 PM (in response to luxspes)So, for example, instead of saying:
<a4j:commandButton value="update" reRender="infoBlock"/> ... <h:panelGrid id="infoBlock"> ... </h:panelGrid>
we would be able to say<a4j:commandButton value="update" reRenderEvent="stuffIsUpdated"/> ... <a4j:region reRenderEvent="stuffIsUpdated"> <h:panelGrid > ... </h:panelGrid> </a4j:region>
o maybe:<a4j:commandButton value="update" reRenderEvent="stuffIsUpdated"/> ... <h:panelGrid > <a4j:support reRenderEvent="stuffIsUpdated"/> ... </h:panelGrid>
This approach, has (IMHO) some key advantages:
First there is no need to have an id for the panelGrid (we can leave it as a short bandwith saving autogenerated id), another (decoupling) advantage is that the commandButton does not need to know that the panelGrid exists, it does not care if it is in the same .xhtml file, if it is inside many calls to ui:include, and new "subscribers" to the stuffIsUpdated can be easily added, without having to modified the code of the commandButton.
So.... what do you think about this? Is it doable? -
2. Re: Inversion of re-render (subscription based re-rendering)
nbelaevski Apr 19, 2009 7:29 AM (in response to luxspes)Hello,
Here is the idea just from the top of head:<a4j:commandLink value="First"> <f:setPropertyActionListener value="firstEvent" target="#{eventBean.event}"/> </a4j:commandLink> <br /> <a4j:commandLink value="Second"> <f:setPropertyActionListener value="secondEvent" target="#{eventBean.event}"/> </a4j:commandLink> <a4j:outputPanel layout="block"> <f:attribute name="ajaxRendered" value="#{eventBean.event == 'firstEvent'}"/> First event panel: <h:outputText value="#{time}"> <f:convertDateTime type="time" timeStyle="long" /> </h:outputText> </a4j:outputPanel> <a4j:outputPanel layout="block"> <f:attribute name="ajaxRendered" value="#{eventBean.event == 'secondEvent'}"/> Second event panel: <h:outputText value="#{time}"> <f:convertDateTime type="time" timeStyle="long" /> </h:outputText> </a4j:outputPanel>
<managed-bean> <managed-bean-name>time</managed-bean-name> <managed-bean-class>java.util.Date</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <managed-bean> <managed-bean-name>eventBean</managed-bean-name> <managed-bean-class>EventBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean>
EventBean holds generated events (in my simple case it stores only one event):public class EventBean { private String event; public String getEvent() { return event; } public void setEvent(String event) { this.event = event; } }
The whole thing should be easy to implement creating two Facelets tags: one for event producer, the other for event consumer.
Disadvantages of this approach: explicit setting of IDs to re-render together with limitToList="true" is a workaround suggested for this issue: https://jira.jboss.org/jira/browse/RF-3341. So you won't be able to apply this workaround using the code I've posted.
What do you think? -
3. Re: Inversion of re-render (subscription based re-rendering)
luxspes Apr 24, 2009 6:24 AM (in response to luxspes)"nbelaevski" wrote:
Hello,
Here is the idea just from the top of head:Very interesting, I didn't know it was possible to do something like this. I'll test it ASAP :-) . The whole thing should be easy to implement creating two Facelets tags: one for event producer, the other for event consumer. Just to be clear on this: All that would have to be done would be wrapping the code you just write with those faceletes tags (and creating the "EventBean" class? Disadvantages of this approach: explicit setting of IDs to re-render together with limitToList="true" is a workaround suggested for this issue: https://jira.jboss.org/jira/browse/RF-3341. So you won't be able to apply this workaround using the code I've posted. I am sorry but I don't really get what are you saying here, in you example code none of you tags has is IDs explicitly set... Could you please post an example that shows when IDs would need to be explicitly set? Assuming there is a case when IDs will need to be explicitly set... What do you think? Great, thanks for the answer
-
4. Re: Inversion of re-render (subscription based re-rendering)
nbelaevski Apr 28, 2009 6:00 AM (in response to luxspes)"luxspes" wrote:
Just to be clear on this: All that would have to be done would be wrapping the code you just write with those faceletes tags (and creating the "EventBean" class?
Yes."luxspes" wrote:
I am sorry but I don't really get what are you saying here, in you example code none of you tags has is IDs explicitly set... Could you please post an example that shows when IDs would need to be explicitly set?
Assuming there is a case when IDs will need to be explicitly set...
The approach provided uses dynamic "ajaxRendered" attribute to implement re-render on event. But if limitToList=true then ajaxRendered=true components are not re-rendered if they are not explicitly specified in a set of components to be re-rendered, so this approach will break in this case.