2013-02-14 12 views
6

p:dataTableに問題があり、1行選択から列を除外しています。Primefaces:p:dataTableの行選択から列を除外する

私は自分のdataTableに4列あります。 fileId、fileName、uploadDateを表示するには、最初の3つが必要です。第4列には、ファイル処理の動作を開始する各行のコマンドボタンがあります。 また、ファイルの詳細ページに移動する行選択(イベントの場合はajaxアクション)もあります。 今、(ボタンを含む)行のどこかをクリックすると、詳細ページに移動します。

私の現在のコードがあります:

<h:form> 
    <p:dataTable id="billingFiles" value="#{billingFiles}" 
     var="billingFile" 
     rowKey="#{billingFile.billingFile.idBillingFile}" 
     filteredValue="#{billingService.filteredBillingFileDataModels}" 
     selectionMode="single" paginator="true" rows="10"> 

     <p:ajax event="rowSelect" listener="#{billingService.selectBillingFileRow}" /> 

     <p:column sortBy="#{billingFile.id}" 
      filterBy="#{billingFile.id}" id="idFile" 
      headerText="#{msg['billing.file.id']}" 
      filterMatchMode="contains"> 
      <h:outputText value="#{billingFile.id}" /> 
     </p:column> 

     <p:column sortBy="#{billingFile.uploadDate}" 
      filterBy="#{billingFile.uploadDate}" id="uploadDate" 
      headerText="#{msg['billing.file.upload_date']}" 
      filterMatchMode="contains"> 
      <h:outputText value="#{billingFile.uploadDate}" /> 
     </p:column> 

     <p:column sortBy="#{billingFile.fileName}" 
      filterBy="#{billingFile.fileName}" id="fileName" 
      headerText="#{msg['billing.file.file_name']}" 
      filterMatchMode="contains"> 
      <h:outputText value="#{billingFile.fileName}" /> 
     </p:column> 

     <p:column id="loadBillingFile"> 
      <p:commandButton id="loadBillingFileButton" 
       rendered="#{billingFile.fileStatus.equals('UPLOADED')}" 
       value="#{msg['billing.load_billing_file']}" 
       action="#{billingService.loadBillingFile(billingFile.billingFile)}" 
       update=":form" /> 
     </p:column> 
    </p:dataTable> 
</h:form> 

はまた、詳細ページをファイルにナビゲートする方法があります:

public void selectBillingFileRow(SelectEvent event) { 
    BillingFileDataModel billingFileDataModel = (BillingFileDataModel) event.getObject(); 
    if (billingFileDataModel != null) { 
     selectedBillingFile = billingFileDAO.findBillingFileById(billingFileDataModel.getBillingFile().getIdBillingFile()); 
     FacesContext.getCurrentInstance().getExternalContext() 
     .getRequestMap().put(JsfView.EVENT_KEY, "viewBillingFile"); 
    } 
} 

は、行選択からボタンの列を除外する方法はありますか?他のページに移動せずに、ファイルの処理を開始する必要があります。

+0

処理するファイルは何ですか、それはdbですか? –

+0

Springバッチでtxtファイルの処理を開始します。 – Rozart

+1

行をクリックするたびに、次のリスナを実行するdataTableにrowSelect Primefaces Ajaxイベントがあります。 ''#{billingService.selectBillingFileRow} "'このメソッドのリダイレクトまたはフォワードを確認するコードを探しますページ。 –

答えて

4

私の問題を部分的に解決しました。 onClickイベントが発生したときに、rowSelect ajaxアクションが実行されないようにしました。

私は p:commandButtonに次の行を追加:

onclick="event.stopPropagation();" 

は、私はボタンで列をクリックではなく、ボタン自体に、まだrowSelectアクションを実行しますので、それは、部分的に働くと述べました。

+0

もう一つの大きな選択肢は、 'SelectEvent'のソースを(getComponent()から)選択的に取得し、イベントをトリガーするコンポーネントのタイプに基づいてメソッド本体の残りの部分を選択的に実行することです – kolossus

関連する問題