2013-05-27 2 views
2

p : dataTable 내의 p : commandButton에 문제가 있습니다. 내 버튼이 내 Backing Bean의 프로 시저를 호출하지 않습니다. 왜이 버튼이 작동하지 않는 사람이 있습니까?p : p : dataTable의 commandButton

안부

버튼 코드 :

<p:column headerText="Details" style="width: 10px;"> 
          <p:outputPanel id="buttonDetail"> 
           <p:commandButton icon="ui-icon-vwfList" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.selectHistoryElement()}" 
               id="buttonDetail"           
               update=":historyDetail" 
               title="GO!!!"> 
           </p:commandButton> 
          </p:outputPanel> 
         </p:column> 
JSF 페이지의

전체 코드 : 콩을 백업

<?xml version="1.0" encoding="UTF-8"?> 
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:m="http://java.sun.com/jsf/composite/components/mmnet"> 

     <h:form id="historyList"> 


       <p:dataTable id="historyTable" 
          value="#{customerChangeHistoryListHandler.dataModel}" 
          var="_history" 
          lazy="true" 
          paginator="true" 
          rows="20" 
          paginatorAlwaysVisible="false" 
          paginatorPosition="bottom" 
          rowsPerPageTemplate="5,10,15,20,25,50" 
          paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
          selectionMode="single" 
          selection="#{customerChangeHistoryHandler.entity}" 
          style="margin-top:5px;"> 


       <f:facet name="header"> 
        <h:outputText value="#{labels.historie} (#{customerChangeHistoryListHandler.dataModel.rowCount})"/> 
       </f:facet> 

        <p:ajax event="rowSelect" listener="#{customerChangeHistoryHandler.onRowSelect}" update=":contentPanel"/> 

         <p:column headerText="#{labels.typ}" 
          style="width: 10px;"> 
          <p:outputPanel id="buttonImage"> 
           <p:commandButton icon="ui-icon-workflow" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.onRowSelect}" 
               update=":contentPanel" 
               rendered="#{_history.changeType == 'WORKFLOW_CHANGED' or _history.changeType == 'WORKFLOW_CREATED' or _history.changeType == 'WORKFLOW_DELETED'}"> 
           </p:commandButton> 
           <p:commandButton icon="ui-icon-note" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.onRowSelect}" 
               update=":contentPanel" 
               rendered="#{_history.changeType == 'NOTE_CHANGED' or _history.changeType == 'NOTE_CREATED' or _history.changeType == 'NOTE_DELETED'}"> 
           </p:commandButton> 
           <p:commandButton icon="ui-icon-diso" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.onRowSelect}" 
               update=":contentPanel" 
               rendered="#{_history.changeType == 'ERP_CHANGE'}"> 
           </p:commandButton> 
           <p:commandButton icon="ui-icon-info" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.onRowSelect}" 
               update=":contentPanel" 
               rendered="#{_history.changeType == 'CUSTOMER_MERGED'}"> 
           </p:commandButton> 
           <p:commandButton icon="ui-icon-arrowthickstop-1-s" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.onRowSelect}" 
               update=":contentPanel" 
               rendered="#{_history.changeType == 'FILE_UPLOADED'}"> 
           </p:commandButton> 
          </p:outputPanel> 
         </p:column> 

         <p:column headerText="Details" style="width: 10px;"> 
          <p:outputPanel id="buttonDetail"> 
           <p:commandButton icon="ui-icon-vwfList" 
               styleClass="colButton" 
               action="#{customerChangeHistoryHandler.selectHistoryElement()}" 
               id="buttonDetail"           
               update=":historyDetail" 
               title="GO!!!"> 
           </p:commandButton> 
          </p:outputPanel> 
         </p:column> 

         <p:column headerText="ChangeType" 
            sortBy="#{_history.changeType}"> 
          <h:outputText value="#{labels[_history.changeType]}" /> 
         </p:column> 

         <p:column headerText="#{labels.beschreibung}"> 
          <h:outputText value="#{_history.description}" /> 
         </p:column> 

         <p:column headerText="#{labels.modDate} und #{labels.modUser}" 
           sortBy="#{_history.modDate}"> 
          <m:outputDateUser valueDate="#{_history.modDate}" valueUser="#{_history.modUser}" /> 
         </p:column> 

       </p:dataTable> 

     </h:form> 

     <h:form id="historyDetail"> 

       <p:panel id="detailPanel" rendered="#{customerChangeHistoryHandler.entity != null}"> 
       History Detail --> ToDo 
       </p:panel> 

     </h:form> 

</ui:composition> 

:

import javax.inject.Inject; 
import javax.inject.Named; 

import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped; 
import org.primefaces.event.SelectEvent; 

@Named 
@ViewAccessScoped 
public class CustomerChangeHistoryHandler extends JccPersistenceHandler<Integer, CustomerChangeHistory>{ 

    @Inject 
    NewsMessageHandler newsMessageHandler; 

    @Inject 
    DebitorenakteState debitorenakteState; 

    @Inject 
    private WorkflowHandler workflowHandler; 


    @Override 
    protected Class<CustomerChangeHistory> getEntityType() { 
     return CustomerChangeHistory.class; 
    } 

    @Override 
    public CustomerChangeHistory getEntity() { 
     return super.getEntity(); 
    } 

    @Override 
    public void onRowSelect(SelectEvent event) { 
     Integer tmpId = this.entity.getLinkedId(); 
     try { 
      ChangeType tmpChangeType = this.entity.getChangeType(); 
      if(tmpChangeType.equals(CustomerChangeHistory.ChangeType.WORKFLOW_CHANGED) || tmpChangeType.equals(CustomerChangeHistory.ChangeType.WORKFLOW_CREATED) || tmpChangeType.equals(CustomerChangeHistory.ChangeType.WORKFLOW_DELETED)){ 
       workflowHandler.setSelectionId(tmpId); 
       workflowHandler.selectById(); 
       workflowHandler.select(); 
      } else if(tmpChangeType.equals(CustomerChangeHistory.ChangeType.NOTE_CHANGED) || tmpChangeType.equals(CustomerChangeHistory.ChangeType.NOTE_CREATED) || tmpChangeType.equals(CustomerChangeHistory.ChangeType.NOTE_DELETED)){ 
       newsMessageHandler.setSelectionId(tmpId); 
       newsMessageHandler.selectById(); 
       newsMessageHandler.onRowSelect(event); 
       debitorenakteState.setActivePage(DebitorenakteEnvironment.PAGE_MORE_NOTES); 
       debitorenakteState.setActiveTabIndex(6); 
      } else if(tmpChangeType.equals(CustomerChangeHistory.ChangeType.ERP_CHANGE)){ 

       //TODO 

      } else if(tmpChangeType.equals(CustomerChangeHistory.ChangeType.CUSTOMER_MERGED)){ 

       //TODO 

      } else if(tmpChangeType.equals(CustomerChangeHistory.ChangeType.FILE_UPLOADED)){ 

       //TODO 

      } else { 
       logError("ChangeType nicht gefunden: " + this.entity.getChangeType().toString()); 
      } 
      super.onRowSelect(event); 
     } catch (Exception e) { 
      // TODO: handle exception 
      jsfMessageService.info("Eintrag nicht mehr vorhanden", event); 
     } 
    } 

    public void selectHistoryElement(){ 
     System.out.println("<-------------------------YEA, Button pressed!!! --------------------------------->"); 
//  logDebug("Showing History Entity: " + this.entity); 
    } 

} 

데이터 모델 RequestScoped에 대해 Bean을 사용할 수있는 방법이 있습니까?

+1

'commandButton/commandLink'가 호출되지 않는 문제에 대한 @BalusC의 [이 우수 답변] (http://stackoverflow.com/a/2120183/332248)을 확인 했습니까? – Jens

+1

한 가지 더 : 'EL'에 대괄호를 남겨 둡니다. '# {customerChangeHistoryHandler.selectHistoryElement()} '대신'# {customerChangeHistoryHandler.selectHistoryElement}'를 작성하십시오. 그래도 도움이되지 않으면 bean의 코드, 즉'selectHistoryElement()'메소드를 보여줍니다. – Jens

+0

@BalusC의 답은 매우 흥미 롭습니다. 다시 읽겠습니다. 두 번째 생각은 아무런 효과가 없습니다. 정보 만 있으면 onRowSelect ajax 이벤트가 정상적으로 작동합니다. mehtod "selectHistoryElement"는 메소드가 호출되었음을 보여주기 위해 현재 시스템에는 특별한 것이 없습니다. – LStrike

답변

4

문제점을 발견했습니다. 첫 번째 데이터 테이블에 대한 데이터 모델을 제공하는 두 번째 빈이 있습니다. 이 빈은 RequestScoped 였고 ViewAccessScoped가 기본 백킹 빈이 아니 었습니다. 범위를 변경하고 버튼 호출이 작동 중입니다.

관련 문제