I have a question. How do I load a new xhtml file to p:panel using a button and still change the url. I would like to use a command button to load a new xhtml file to p:panel but i still want the websites url to change.
Why I want to do this.
I want to do this because i want my website to have multiple pages with my toolbar in each page. I don't want to have to duplicate the code for my toolbar in each page. -dose that make sense? If anyone know how to help please let me know.
My code. index.xhtml
Scroll done till you find p:panel with the class value "ClassPanel" When a button in my toolbar is clicked i would like the p:panel to load a new xhtml file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>LEEXV</title>
</h:head>
<h:body>
<style>
</style>
<h:form >
<p:growl id="messages"/>
<p:toolbar id="stickymenu" style=" max-height:60px; margin-top: auto; ">
<f:facet name="left">
<f:facet name="left">
</f:facet>
<f:facet name="right">
<p:growl id="growl" life="2000"/>
<p:inputText style="margin-right:40px;" placeholder="Search Crawly"/>
<p:spacer width="10px;"/>
<p:commandButton value="Ajax Action" action="#{navigationView.gotoSecond}" style=" width: 90px; height: 40px;"/>
<p:spacer width="20px;" />
<p:commandButton id="Support" type="ComButton" style=" width: 90px; height: 40px;" value="Donate"/>
<p:tooltip id="toolTipGrow" for="Support" value="Find out how you can help us help you!"
showEffect="clip" hideEffect="explode" />
<p:spacer width="20px;"/>
<p:commandButton type="ComButton" style=" width: 90px; height: 40px;" value="Update"/>
<p:spacer width="20px;"/>
<p:commandButton type="ComButton" style="width: 90px; height: 40px; margin-top: 6px;" value="Shop"/>
</f:facet>
</f:facet>
<f:facet name="right">
</f:facet>
</p:toolbar>
<p:sticky target="stickymenu"/>
</h:form>
<p:panel class="ClassPanel" >
<ui:composition id="LoadNewpages">
<ui:param id ="" name="defaultHeader" value="#{HomeHtml.gotoSecond}" />
</ui:composition>
</p:panel>
</h:body>
</html>
My code. newjsf.xhtml
This is the code i would like to load in the panel.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<body>
<h:outputText value="hello"/>
</body>
</html>
My code. NavigationView.java
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class NavigationView implements Serializable {
public String gotoSecond() {
return "newjsf";
}
}
If you don't understand please just try and help me with this part.. I have a history of asking bad question
How do i use a button to load xhtml files. Basically, how do i load xhtml file dynamically to p:panel.