Skip to Main Content

conditional render attribute -- how to achieve this behavior?

1011675May 29 2013 — edited May 29 2013
hi,

the easiest way to explain the behavior i want is the following:

sometimes, i want:

<h:commandButton id="myButton" action="#{myBean.doSomething}">
<f:ajax render="displayArea"/>
</h:commandButton>

and other times i want (render nothing):

<h:commandButton id="myButton" action="#{myBean.doSomething}">
<f:ajax render=""/>
</h:commandButton>

so basically, i have an area on my page that i want to render intelligently based on clicking a button. when clicking the button, if doSomething() is successful i want to re-render the "displayArea" div, however, if the result of doSomething() is unsuccessful, i do not want anything to happen to the "displayArea" div (that is, i want it to be left completely alone and untouched -- still retaining the contents from the previous successful render).

essentially, i want to re-render an area only when it suits me. i do not even want to re-render that area with the same contents as the last successful action because that area is scrollable and doing so would lose the user's scrolling position by re-rendering it, even if only re-rendering the same contents.

is there any way to achieve this specific type of "conditional render attribute" behavior?

thanks in advance for any suggestoins!
-victor
Comments
Post Details
Added on May 29 2013
4 comments
3,134 views