2013-11-12 3 views
0

Я работаю над веб-приложением, используя PrimeFaces, JPA, Hibernate и JSF 2.0.Кнопки не действуют в JSF

У меня есть эта страница 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; 
} 
+3

Вы уверены? '' имеет встроенную функцию 'ajax'. Попробуйте установить 'ajax = false' в commandButton – SRy

+0

Похоже, у вас есть ошибка проверки или конверсии при отправке формы. Добавьте '' в вашу форму, чтобы увидеть ошибки при отправке формы. –

+0

@SRy, когда я добавил 'ajax = false' Я получил эту ошибку' Не могу удалить один и тот же компонент дважды: j_idt12: j_id2' –

ответ

1

Спасибо всем.

Я решил проблему, я забыл генерировать методы hashCode() и equals() для моего конвертера.

Смежные вопросы