This one is a real head scratcher... I have a number of command links which are styled as buttons so in order to enable easy maintenance, I have written a little html fragment that I can include with some parameters to render a nicely styled command link.
Now this works great except when the action outcome is to change view, at which point, the "include" version steadfastly refuses to obey the click to navigate and I have no idea why! If the action results in a validation error, the errors are shown so the action is definitely being called - and my logs confirm this, however, if there are no validation errors, the original version, without using the include, will navigate to the next page just fine, but the version using include will not navigate. I have tried with a very simple "hello.xhtml" page as the second page so I know it can't be anything to do with the contents of the new view.
Edited for clarity: I use several buttons on the page, most of which just modify the state of the current page and these are all working fine. It's only when the outcome is to change view that things go wrong with the "include" version.
I'm running JSF 1.2 on top of Portal Server 6.1/WAS 7.0
I've spent too long trying to figure this out so over to you guys to see if you have any ideas...
Update: To save wading through the comments, the answer is I was using from-action in my navigation rules, which just matches the string used in the commandLink - so the navigation handler was seeing #{bean[action]} as the from-action rather than #{applicationPage.doContinue}
Some code.
My button template:
<ui:composition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xml:lang="en" lang="en"> <ui:remove> Functional Button with arrow icon. Parameters: linkId = The id for the commandLink. linkText = The text to display on the button. linkTitle = title text to display bean = The bean name containing the action handler. action = The action handler to call. </ui:remove> <div class="btn functionalButton"> <h:commandLink id="#{linkId}" action="#{bean[action]}" title="#{linkTitle}" styleClass="functional"> #{linkText} <span class="arrow icon" /> <span class="tl" /> <span class="tr" /> <span class="bl" /> <span class="br" /> </h:commandLink> </div> </ui:composition> And an example of use on a page:
<ui:include src="/WEB-INF/facelets/content/functionalButton.xhtml"> <ui:param name="linkId" value="applicationSubmit" /> <ui:param name="bean" value="#{applicationPage}" /> <ui:param name="action" value="doContinue" /> <ui:param name="linkText" value="#{msg['button_FF060_continue']} " /> </ui:include> This version won't change view.
Prior to using the include, the code looked like this (which should resolve and render to the exact same html) and yet this version changes view just fine.
<div class="btn functionalButton"> <h:commandLink id="applicationSubmit" styleClass="functional" action="#{applicationPage.doContinue}" title="#{msg['button_FF060_continue']}"> #{msg['button_FF060_continue']} <span class="arrow icon" id="arrow_continue" /> <span class="tl" /> <span class="tr" /> <span class="bl" /> <span class="br" /> </h:commandLink> </div>
doContinue()is never called when a validation error occurs. What you probably meant to say is that the form is properly submitted. As to the concrete problem, well I'm not sure, it's probably because you used an include file instead of a tag file. In a tag file the given syntax should undoubtely work for Facelets 1.x. I only don't have a Facelets 1.x playground environment right now to play around with the include file approach.