내에서는 dataTable
각 기사를 특정 작업과 연결하고 있습니다.
a의 클릭에 commandButton
작업을 보여줍니다 최대의 목록, 그래서, 작업의 선택의 특정 세포 업데이트에서 원하는 dataTable
( outputText
과를 id="columnTache"
내의 나머지 부분을 업데이트하지 않고) dataTable
.
<p:dataTable value="#{myController.articleList}"
id="tabArticle"
var="article"
rowKey="#{article.id}" >
<p:column headerText="quantite" >
<pe:inputNumber value="#{article.quantite}" />
</p:column>
<p:column headerText="taches" >
<h:outputText value="#{article.tache.libelleTache}" id="columnTache" />
</p:column>
<p:column headerText="taches" >
<p:commandButton oncomplete="PF('dialogTasks').show();" update=":formSelectAffecterTache">
<p:ajax event="click" listener="#{myController.setArticle(article)}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:dialog header="#{bundleTech.lbl_taches}" widgetVar="dialogTasks" >
<h:panelGrid columns="1" >
<h:form id="formSelectAffecterTache">
<ui:include src="/pages/listTacheSelect.xhtml">
<ui:param name="bean" value="#{myController}" />
<ui:param name="action" value="affecterTache" />
</ui:include>
</h:form>
</h:panelGrid>
</p:dialog>
my의 업데이트 dataTable
는 관리 빈에 있습니다.
public void affecterTache() {
article.setTache(selectedSingleTache);
RequestContext.getCurrentInstance().update("form:tabArticle");
}
A dataTable
는 이름 지정 컨테이너이므로 그 안의 구성 요소 앞에 dataTable
의 id
. 또한 테이블 (각 행)에 표시된 데이터의 각 반복은 생성 된에 영향을줍니다 id
. 양식도 이름 지정 컨테이너이기 때문에 outputText
구성 요소 는 첫 번째 행, 두 번째 행 등에서 id
생성됩니다 .formId:tabArticle:0:columnTache
formId:tabArticle:0:columnTache
당신은 설정 할 경우 id
에 commandButton
당신은 얻을 것이다 formId:tabArticle:0:myButton
, formId:tabArticle:1:myButton
당신은이를 사용할 수있는 등의 id
대응을 만들려면 클릭 핸들러에서 inputText
clientId
. 그러나 article
메소드에 전달 하기 때문에 어떤 버튼이 클릭되었는지 확인할 수 없습니다. 따라서 먼저 클릭 리스너 메소드를 다음과 같이 변경하십시오.
public void useArticle(AjaxBehaviorEvent event) {
UIComponent component = event.getComponent();
}
이제 어떤 버튼이 클릭되었는지 ( event.getComponent()
) 알고 있지만, 당신도 필요합니다 article
. XHTML의 버튼에 속성으로 설정할 수 있습니다.
<p:commandButton id="myButton"
oncomplete="PF('dialogTasks').show();"
update=":formSelectAffecterTache">
<p:ajax event="click"
listener="#{myController.useArticle}" />
<f:attribute name="article"
value="#{article}" />
</p:commandButton>
이 속성은 리스너에서 읽을 수 있습니다.
Article article = (Article) component.getAttributes().get("article");
이제를 업데이트 inputText
하려면 버튼의 clientId
다음을 사용하십시오 .
String update = component.getClientId().replace(":myButton", ":columnTache");
빈에 저장하고 준비가되면 다음을 업데이트합니다.
RequestContext.getCurrentInstance().update(update);
또한보십시오:
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다