I am facing a design issue. My co-worker complains I use one controller bean in .xhtml file to handle all the business logics.
So I want to separate the original controller into two controllers.
One controller(createFeature) is to add new entry. Another controller(manageFeatures) is to show all the entries(including the new one).
My issue is when new entry is created, it can't be show .
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
</h:head>
<h:body>
<h1 class="title ui-widget-header ui-cornet-all">Feature</h1>
<div class="entry">
<h:form id="form">
<p:panel header="Create a new feature">
<h:panelGrid id="create" columns="2" columnClasses="lable,value">
<h:outputLabel value="Feature : *" for="txt_feature"/>
<p:inputText id="txt_feature" value="#{createFeature.feature.feature}" required="true"/>
<h:outputLabel value="Score : *" for="txt_score"/>
<p:inputText id="txt_score" value="#{createFeature.feature.score}" required="true"/>
<h:panelGroup>
<p:commandButton value="Reset" type="reset" async="false"/>
<p:commandButton value="Submit" actionListener="#{createFeature.save}" update="create, manage"/>
</h:panelGroup>
</h:panelGrid>
</p:panel>
<p:dataTable id="manage" var="feature" value="#{manageFeatures.features}">
<p:column sortBy="#{feature.feature}" filterBy="#{feature.feature}">
<f:facet name="header">
<h:outputText value="Feature"/>
</f:facet>
<h:outputText value="#{feature.feature}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Score"/>
</f:facet>
<h:outputText value="#{feature.score}"/>
</p:column>
</p:dataTable>
</h:form>
</div>
</h:body>
</html>
Can you help me to fix this issue?
Thank you,
Colin.B.Wang