2017-02-06 4 views
0

p:datagridのcelleditor内のp:commandLinkまたはp:commandButtonが機能していません。commandLinkをクリックすると、同じページにリダイレクトされます。 celleditorの中でcommandLinkはリスナーを見つけることはできませんが、celleditorの外に置くと完全に動作します。p:datagridのp:celleditor内のp:commandLinkは機能しません

<h:form id="form"> 

    <p:growl id="msgs" showDetail="true"/> 
        <p:dataTable id="project" var="car" value="#{editdeleteview.proj_rec}" rowKey="#{car.id}" selection="#{editdeleteview.selected_rec}" selectionMode="single" editable="true" style="margin-bottom:20px"> 
       <f:facet name="header"> 
        All Projects 
       </f:facet> 

       <p:ajax event="rowEdit" listener="#{editdeleteview.onRowEdit}" update=":form:msgs"/> 
       <p:ajax event="rowEditCancel" listener="#{editdeleteview.onRowCancel}" update=":form:msgs"/> 

       <p:column headerText="ID"> 

         <h:outputLabel value="#{car.id}" /> 


       </p:column> 
       <p:column headerText="Title"> 
       <p:commandLink ajax="false" action="#{editdeleteview.openObjects(car)}" ><h:outputText value="#{car.title}" /></p:commandLink> 
        <p:cellEditor> 
         <f:facet name="output"><p:commandLink ajax="false" action="#{editdeleteview.openObjects(car)}" ><h:outputText value="#{car.title}" /></p:commandLink></f:facet> 
         <f:facet name="input"><p:inputText value="#{car.title}" style="width:100%"/></f:facet> 
        </p:cellEditor> 
       </p:column>     
       <p:column headerText="Description"> 
        <p:cellEditor> 
         <f:facet name="output"><h:outputText value="#{car.description}" /></f:facet> 
         <f:facet name="input"><p:inputText value="#{car.description}" style="width:100%"/></f:facet> 
        </p:cellEditor> 
       </p:column> 
       <p:column headerText="Insertion Time"> 
        <p:cellEditor> 
         <f:facet name="output"><h:outputText value="#{car.insertionTimestamp}" /></f:facet> 
         <f:facet name="input"><p:inputText value="#{car.insertionTimestamp}" style="width:100%"/></f:facet> 
        </p:cellEditor> 
       </p:column> 
       <p:column headerText="Close Time"> 
        <p:cellEditor> 
         <f:facet name="output"><h:outputText value="#{car.closeTimestamp}" /></f:facet> 
         <f:facet name="input"><p:inputText value="#{car.closeTimestamp}" style="width:100%"/></f:facet> 
        </p:cellEditor> 
       </p:column> 



       <p:column headerText="Edit" style="width:50px"> 
        <p:rowEditor /> 
       </p:column> 
       <p:column headerText="Delete"> 
        <p:commandButton id="downloadLink1" value="Delete" ajax="false" class="btn btn-danger" icon="ui-icon-trash" action="#{editdeleteview.delete(car)}"> 

        </p:commandButton> 
       </p:column>     
      </p:dataTable>    

    </h:form> 

P:列のタイトルの下にcellEditorを外のcommandLinkが完璧に機能していますが、cellEditorを内のcommandLinkが動作していない、Bean内のリスナーは、私もこのcommandLink in cellEditor doesn't trigger action/actionListenerを試してみました

public String openObjects(Project p) 
{ 


    HttpSession session = SessionUtils.getSession(); 
    session.setAttribute("project_id", p.getId()); 
    session.setAttribute("project_title", p.getTitle()); 
    //session.setAttribute("project_title", "Hamdan"); 
    System.out.println("EditView: "+session.getAttribute("project_title").toString()); 
    return "Objects.xhtml"; 

} 

ですしかしそれは私のために働いていませんでした。どんな助力も高く評価されます。

+0

'動作しない' 漠然とへの道である動作します。あなたの他の質問の1つは何かの重複としてマークされています。その複製には、さらにデバッグする方法に関する情報が含まれています。してください。 – Kukeltje

+0

@Kukeltjeまた、私はそれらを試してみましたが、私は列 "title"の下のcellEditor内のコマンドリンクがリスナーを呼び出さず、エラーなしで同じページにリダイレクトするという問題を述べました。 –

+0

@Kukeltje cellEditorタグ外のcommandLinkは完全に動作していますが、cellEditor内のcommandLinkを動作させたいと思います。 –

答えて

0

コマンドリンクコンポーネントにimmediate="true"を設定してみてください。 は@BalusCでこの説明を見てください:

Trying to understand immediate="true" skipping inputs when it shouldn't

+0

cellEditorの外側のcommandButtonが機能するので、これが解決策であれば、cellEditorのコンテキストでは**が**必要で**はその外側にない**という理由を説明すると良いでしょう。 – Kukeltje

+0

私はそれが動作する場合の解決策として提案しています。実際に自分自身でそれを試していない。しかし、私は、cellEditor内のcommandLinkのリクエストがcellEditor自身のイベントまたは私が推測しているリクエストによって調整される可能性があるため、この問題が解決されると思います。 @Kukeltje答えがルールに準拠していない場合は、自由に投票してください。何恨みっこない。 :) –

+1

いいえ、ないdownvote以来、私はそれが役立つかどうかわからない。しかし、あなたが試していない場合は、次のような短いコメントをコメントとして投稿し、それが助けになったら答えに変えてください。質問に記載されている 'process =" this "は、あなたが記述した内容を解決するか、解決するはずです – Kukeltje

0

だけでこれを使用し、それが

<f:facet name="output"> 
          <p:commandLink action="#{editdeleteview.openObjects(car)}" 
           process="@this" immediate="true"> 
           <h:outputText value="#{car.title}" /> 
           <f:setPropertyActionListener 
            target="#{editdeleteview.selected_rec}" value="#{car}" /> 
          </p:commandLink> 
         </f:facet> 
関連する問題