-
1. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
dageisz Jun 19, 2013 2:56 PM (in response to javacoryd)Can you show the corresponding markup?
I guess you are trying to render the button itself when the condition changes. That does not work cause the jsf.js implementation replaces the content of a dom element.
I've had a similar effect when trying to show a previously not rendered element again. You have to render the container that holds the element to hide/show it (replacing something that does not exist is indeed difficult ;-) ).
see this example:
<a4j:commandLink id="link1" render="l1 cntr1" action="#{bean.toggleCondition} value="toggle" /> <!-- this one will not show/hide correctly! --> <a4j:commandLink id="l1" rendered="#{bean.condition}" .. ./> <h:panelGroup id="cntr1"> <!-- this one will be rendered or not rendered based on the condition, but cause we are rerendering the surrounding group it works just fine --> <a4j:commandLink id="l2" rendered="#{bean.condition}" .. ./> </h:panelGroup>
Hope that helps.
-
2. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
javacoryd Jun 19, 2013 3:07 PM (in response to dageisz)Hey thanks for the response.
The actual hide/show is working correctly. I will take your example to explain. Notice I added an action to the commandLink with id of "l2":
<a4j:commandLink id="link1" render="l1 cntr1" action="#{bean.toggleCondition} value="toggle" />
<!-- this one will not show/hide correctly! -->
<a4j:commandLink id="l1" rendered="#{bean.condition}" .. ./>
<h:panelGroup id="cntr1">
<!-- this one will be rendered or not rendered based on the condition, but cause we are rerendering the surrounding group it works just fine -->
<a4j:commandLink id="l2" rendered="#{bean.condition}" action="#{bean.doSomething}".. ./>
</h:panelGroup>If, at the time the screen renders, the value of #{bean.condition} is true, when I go to click the link with id of "l2" everything works great. If #{bean.condition} is false when the screen renders and then I click the toggle link ( link with the id of "link1" ) the link with id of "l2" is shown. However, when I go to click the link "l2" now, the action doesn't get called.
Cory.
-
3. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
dageisz Jun 21, 2013 4:27 AM (in response to javacoryd)If you use it like this, there should be no problem.
Did you check if JavaScript errors occur and/or embedd a4j:log to see what's happening?
-
4. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
javacoryd Jun 21, 2013 9:16 AM (in response to dageisz)Yea, I will look and see what a4j:log has to say.
Thanks.
-
5. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
javacoryd Jun 21, 2013 10:16 AM (in response to javacoryd)Ok so here is some more information on this.
On my page I have a <h:form> with some <a4j:commandLink>s under the form and also a <h:dataTable> with some <a4j:commandLink>s in the dataTable. The "toggle" link ( like link1 ) re-renders the form after the toggle so it's re-rendering the parent of all of the links.
Some of the links that are conditionally rendered simply exist under the form while others exist under the <h:dataTable> which is under the form. The ones that exist under the form call the action if the link is pressed after the link is rendered. So they work fine. The ones that exist under the <h:dataTable> don't call the action when pressed after being conditionally rendered.
So it must have something to do with the links being inside a <h:dataTable>.
Cory.
-
6. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
dageisz Jun 21, 2013 10:25 AM (in response to javacoryd)So the informations you give are hard to handle, at least i can't guess what may be the cause of you problems, cause i never had these. But i m only using rich:dataTable or rich:extendedDataTable (wich may have other issues...)
At least i can only give you the hint to create a minimal example of your code that reproduces your problem and post it here, then you ll have better chances to get help.
-
7. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
javacoryd Jun 21, 2013 10:57 AM (in response to dageisz)<h:form id="interestRateChangeForm" >
<!-- This links toggle the value of "selectedInterestRateType" which is in the context -->
<a4j:commandLink id="fixedLink" value="Fixed Interest Rate"
action="#{interestRateAction.switchType('FIXED')}"
render="interestRateChangeForm"/>
<a4j:commandLink id="variableLink" value="Variable Interest Rate"
action="#{interestRateAction.switchType('VARIABLE')}"
render="interestRateChangeForm"/>
<a4j:commandLink id="customLink" value="Custom Interest Rate"
action="#{interestRateAction.switchType('CUSTOM')}"
render="interestRateChangeForm"/>
<!-- Conditionlly rendered links -->
<!-- When these links are rendered the action works -->
<a4j:commandLink id="perfFixedAction" value="Fixed Rate Action"
action="#{interestRateAction.executeInterestRateAction( interestRate )}"
rendered="#{selectedInterestRateType.equals('FIXED')}"
render="interestRateChangeForm"/>
<a4j:commandLink id="perfVariableAction" value="Variable Rate Action"
action="#{interestRateAction.executeInterestRateAction( interestRate )}"
rendered="#{selectedInterestRateType.equals('VARIABLE')}"
render="interestRateChangeForm"/>
<!-- When the screen renders for the first time, if "selectedInterestRateType" is "CUSTOM"
the links in the dataTable will work and call the action.
If the screen renders for the first time and "selectedInterestRateType is not "CUSTOM"
and the user clicks the customLink ( which renders the links in the dataTable ) the
link doesn't work. -->
<h:dataTable id="customRatesDT" value="#{customRates}" var="customRate" >
<h:column id="loanNumber">
<f:facet name="header">
<h:outputText value="Custom Rate" />
</f:facet>
<a4j:commandLink id="perfCustomAction" value="Custom Rate Action"
action="#{interestRateAction.executeInterestRateAction( customRate )}"
rendered="#{selectedInterestRateType.equals('CUSTOM')}"
render="interestRateChangeForm"/>
</h:column>
</h:dataTable>
</h:form>
-
8. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
bleathem Jun 21, 2013 6:25 PM (in response to javacoryd)Can you try this with RichFaces 4.3.2.Final?
-
9. Re: a4j:commandLink conditionally rendered, not firing action, RichFaces 4.2.2 Final
javacoryd Jun 21, 2013 10:01 PM (in response to bleathem)Yea. I will try that. This is a Seam application and we are upgrading to Seam 2.3 and bundled with this version of Seam is RichFaces 4.2.2 Final. I can try updating the Richfaces jars and see what happens.
I did find a "workaround" which gives the user the same experience:
<h:dataTable id="customRatesDT" value="#{customRates}" var="customRate" >
<h:column id="loanNumber">
<f:facet name="header">
<h:outputText value="Custom Rate" />
</f:facet>
<a4j:commandLink id="perfCustomAction"
action="#{interestRateAction.executeInterestRateAction( customRate )}"
render="interestRateChangeForm">
<h:outputText value="Custom Rate Action" rendered="#{selectedInterestRateType.equals('CUSTOM')}" />
</a4j:commandLink>
</h:column>
</h:dataTable>