PrimeFaces、JPA、Hibernate、および JSF 2.0 を使用して Web アプリケーションに取り組んでいます。
私はこのJSFページを持っています.「保存」と「キャンセル」p:commandButton
は何もしません! 助けてくれませんか?
このページへのリダイレクトのアクション ( action="#{lotController.initLot}"
) :p:commandButton
action="#{lotController.initLot}"
<h:body style="width:600px; ">
<ui:composition template="/common/master-layout.xhtml">
<ui:define name="title">#{message['app.page.main.title']}</ui:define>
<ui:debug
rendered="#{initParam['javax.faces.PROJECT_STAGE'] eq 'Development'}"
hotkey="x" />
<ui:define name="content">
<p:fieldset legend="Création d'un nouveau lot"
style="margin-top: 20px;">
<h:form id="addLotForm">
<p:fieldset legend="Lots techniques" toggleable="true"
toggleSpeed="500"
style="margin-left: 10px; margin-top: 30px; background-color:RGB(225,240,233)">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="Libellé" style="font-weight:bold" />
<p:inputText value="#{lotController.lotToSave.libelle}" />
</h:panelGrid>
</p:fieldset>
<!-- Descriptifs -->
<p:fieldset legend="Descriptifs" toggleable="true"
toggleSpeed="500"
style="margin-left: 10px; margin-top: 30px; background-color:RGB(225,240,233)">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="Libellé" style="font-weight:bold" />
<p:selectOneMenu value="#{lotController.selectedDescriptif}"
effect="fade" converter="#{descriptifConverter}">
<f:selectItems value="#{lotController.listDescriptifs}" var="descriptif"
itemLabel="#{descriptif.libelle}" itemValue="#{descriptif}" />
</p:selectOneMenu>
</h:panelGrid>
</p:fieldset>
<p:commandButton value="Save" id="saveLot"
styleClass="ui-priority-primary"
action="#{lotController.createLot}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:70px">
</p:commandButton>
<p:commandButton value="Cancel" id="cancelLot"
styleClass="ui-priority-primary"
action="#{lotController.cancelLot}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:70px" />
</h:form>
</p:fieldset>
</ui:define>
</ui:composition>
index.xhtml:
<h:form id="listLotsForm">
<p:panel>
<ui:include src="lotDataTable.xhtml" />
</p:panel>
</h:form>
lotDataTable.xhtml:
<p:commandButton value="Ajouter un lot" id="addLot"
styleClass="ui-priority-primary"
action="#{lotController.initLot}"
style="margin-left:10px;margin-bottom:10px;height:125%;width:140px" />
<p:dataTable id="dataTableLot" var="lot" resizableColumns="true"
liveResize="true" paginator="true"
value="#{lotController.listLots}" rows="10" scrollable="false"
style="width: 100%" selection="#{lotController.selectedLot}"
rowKey="#{lot.idLot}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" editable="true">
<p:ajax event="rowEdit" listener="#{lotController.onEdit}"
update=":listLotsForm:messages" />
<p:ajax event="rowEditCancel" listener="#{lotController.onCancel}"
update=":listLotsForm:messages" />
update=":listLotsForm:messages" /> -->
<p:column headerText="N° lot" style="width: 100px">
<h:outputText value="#{lot.idLot}" />
</p:column>
<p:column headerText="Libellé" style="width: 100px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{lot.libelle}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{lot.libelle}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6%">
<p:rowEditor />
</p:column>
<p:column style="width:6%">
<p:commandButton action="#{lotController.deleteLot(lot)}"
icon="ui-icon-trash" title="Supprimer" />
</p:column>
</p:dataTable>
コントローラー:
public String createLot(){
LotDto lot = prepareDtoBeforeSave();
LotDto lotCreated = lotService.create(lot);
clearLot();
init();
return "/views/administration/parametres/lot/listeLots?faces-redirect=true";
}
protected LotDto prepareDtoBeforeSave() {
LotDto lot = new LotDto();
lot.setIdDescriptif(selectedDescriptif);
lot.setLibelle(lotToSave.getLibelle());
return lot;
}