I've been trying to get a menu working with layoutunit. What I'd like to do is have the menu selection load the main content in the centre layout without reloading the whole page. I have achieved that using ajax update. However this seems to have broken my dialog validation. Now when I changed menu options (i.e. load another page in the centre layout, then go back to the original page) the dialog misbehaves - valid input fails ajax validation and the values in the dialog don't update (i.e changing the values in the form always results in the same value being submitted)
One thing I noticed us that setting the dialog to dynamic solves the problem initially - but then in subsequent page swaps it fails again. Alos refreshing the page via the browser also resolves the problem.
What is the correct way to navigate without reloading the whole page using layoutunit?
My code is below:
Index page containing the menu:
Code: Select all
<p:layout style="min-width:400px;min-height:700px;background-color:black">
<p:layoutUnit position="west" resizable="false" size="300" minSize="40" maxSize="200">
<h:form>
<p:menu>
<p:submenu label="Menu">
<p:menuitem value="Stocks" update="optionPanel" actionListener="#{menuView.selectStock}"/>
<p:menuitem value="Portfolio" update="optionPanel" actionListener="#{menuView.selectPortfolio}"/>
</p:submenu>
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<h3 style="margin-top:0">Plain Menu</h3>
<p:outputPanel id="optionPanel">
<ui:include src="#{menuView.view}">
</ui:include>
</p:outputPanel>
</p:layoutUnit>
</p:layout>
Code: Select all
@ManagedBean
@SessionScoped
public class MenuView implements Serializable {
private static final long serialVersionUID = -1015364935820045523L;
private String view;
public void selectStock() {
setView("stocks.xhtml");
}
public void selectPortfolio() {
setView("portfolio.xhtml");
}
public String getView() {
return view;
}
public void setView(String view) {
this.view = view;
}
}
Code: Select all
<p:dialog id="buyDlg" header="Buy Shares" widgetVar="buyDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" appendTo="@(body)" dynamic="true">
<p:outputPanel id="buyDetail" style="text-align:center;">
<p:panelGrid columns="2" columnClasses="label,value" style="margin:auto">
<h:outputText value="Member" />
<h:outputText value="#{stocksView.selectedStock.bidOrderId.member.memberId}" />
<h:outputText value="Party" />
<h:outputText value="#{stocksView.selectedStock.bidOrderId.member.party}" />
<h:outputText value="Price" />
<h:outputText value="#{stocksView.selectedStock.price}" />
</p:panelGrid>
<h:form style="padding-top:10px;">
<p:messages id="Buymsgs" />
<h:panelGrid columns="3" cellpadding="5" style="margin:auto">
<h:outputText value="Amount:" />
<p:inputText id="bidAmount" value="#{stocksView.bidAmount}" required="true" label="BuyAmount" style="max-width:50px;">
<p:ajax update="msgBidAmount" event="keyup" listener="#{stocksView.keyUp}" />
</p:inputText>
<p:message for="bidAmount" id="msgBidAmount" display="icon"/>
<h:outputText value="Price:" />
<p:inputText id="bidPrice" value="#{stocksView.bidPrice}" required="true" label="BuyPrice" style="max-width:50px;">
<p:ajax update="msgPrice" event="keyup"/>
</p:inputText>
<p:message for="bidPrice" id="msgPrice" display="icon"/>
</h:panelGrid>
<p:commandButton process="@this,bidAmount,bidPrice" update="Buymsgs,:form:prices" value="Buy" id="BuyButton" styleClass="ui-priority-primary" style="margin-top:10px;">
<f:actionListener binding="#{stocksView.submitBidOrder()}"/>
</p:commandButton>
</h:form>
</p:outputPanel>
</p:dialog>