我不清楚你的用例是什麼;但從理論上講,您可以使用任何給定組件上的<f:attribute/>
標籤來傳遞參數。
的<f:attribute/>
標記添加到組件發起Ajax調用
<p:commandLink id="aComponent" value="#{bean.val}" action="#{bean.doSomething}">
<f:attribute name="conversationId" value="#{param['cid']}"/>
</p:commandLink>
你可以拉從組件參數圖的參數支持bean:
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot theView = context.getViewRoot();
UIComponent component = theView.findComponent("aComponent");
Integer theConversationId =(Integer) component.getAttributes().get("cid");
這裏的關鍵點是該參數可在#{param}
地圖(與其他GET
參數一樣)。它不會通過ajax自動傳輸的原因是:GET參數需要傳輸完整的HTTP請求。 AJAX的重點在於你可以選擇發送給服務器的內容。