Reputation: 275
I have created a JSF 2 page which uses Facelets to define the structure of the page.
<div class="page">
<div class="content">
<ui:insert name="content">
</ui:insert>
</div>
<div class="footer">
<ui:include src="footer.xhtml" />
</div>
</div>
This is footer.xhtml
<h:commandButton value="Link Page 1" action="page1.xhtml" />
<h:commandButton value="Link Page 2" action="page2.xhtml" />
As you can see, in the footer.xhtml I have some buttons which I use to move between pages.
Unfortunately navigation does not work when buttons are placed into the footer.xhtml page. On the other hand if they are placed in the main div (content) they work correctly.
Is there a way to let them work in the footer too ?
P.s. My environment Java 1.6 on JBoss application server 7 Thanks Linda
Upvotes: 1
Views: 1657
Reputation: 30025
For pure navigation you should use h:button
instead of h:commandButton
. The latter indeed needs a surrounding form as stated by Kris.
If you change your buttons as follows, they should work regardless where you place them on the page:
<h:button value="Link Page 1" outcome="page1" />
<h:button value="Link Page 2" outcome="page2" />
The .xhtml
suffix is appended by JSF.
Upvotes: 2
Reputation: 5792
Your commandButton/commandLink elements wont' work if you don't put them into a form element <h:form></h:form>
.
Remember to add the proper namespace to your <ui:composition>
element 'xmlns:h="http://java.sun.com/jsf/html
'
Upvotes: 1