2014-09-25 66 views
0

我想在CQ5中的對話參與者步驟中獲取有效載荷,這個步驟位於我的小部件監聽器下。在我的對話框的下面。在對話參與者中獲取有效載荷步驟

<?xml version="1.0" encoding="UTF-8" ?> 
    <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="cq:Dialog" title="Changetemplate" xtype="dialog"> 
    <items jcr:primaryType="cq:WidgetCollection"> 
     <Template jcr:primaryType="cq:Panel"> 
      <items jcr:primaryType="cq:WidgetCollection"> 
       <Path jcr:primaryType="cq:Widget" fieldLabel="Select Template" id="mytemplate" name="./jcr:content/templatepath" xtype="textfield"> 
        <listeners jcr:primaryType="nt:unstructured" afterrender="function(component){ var dialog = CQ.wcm.showTemplate('/content/geometrixx/en'); dialog.show(); }" /> 
       </Path> 
      </items> 
     </Template> 
    </items> 
    </jcr:root> 

感謝

回答

1

這可以在Java下面的代碼的幫助下完成的。

public class MyParticipant implements ParticipantStepChooser { 

    @Property(value = "An example.") 
    static final String DESCRIPTION = Constants.SERVICE_DESCRIPTION; 
    @Property(value = "MyComapany") 
    static final String VENDOR = Constants.SERVICE_VENDOR; 
    @Property(value = " Participant Chooser Process") 
    static final String LABEL=ParticipantStepChooser.SERVICE_PROPERTY_LABEL; 

    private static final String TYPE_JCR_PATH = "JCR_PATH"; 

    public String getParticipant(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException { 
     WorkflowData workflowData = workItem.getWorkflowData(); 
     if (workflowData.getPayloadType().equals(TYPE_JCR_PATH)) { 
      String path = workflowData.getPayload().toString(); 

     } 
     return ""; 
    } 
} 

在ECMA腳本

var workflowData = graniteWorkItem.getWorkflowData(); 
    if (workflowData.getPayloadType() == "JCR_PATH") { 
     var path = workflowData.getPayload().toString(); } 

,但如果你想在對話框中該路徑專門嘗試 1. CQ.utils.WCM.getPagePath();

如果上述解決方案不能解決你的問題,然後

  1. 創建一個servlet
  2. 從對話框中選擇該servlet並獲取該servlet中的有效內容(主要是當前路徑)。 參考this網址以供參考。