저는 WebSphere Application Server에서 Apache MyFaces 2와 함께 PrimeFaces 3.3.1을 사용합니다. My BackingBean이 SessionScoped입니다. 전체 폼을 업데이트해야하는 selectOneButton이있는 폼이 있습니다.JSF 라이프 사이클을 PrimeFaces ajax로 2 회 수행
<h:form id="options">
<p:panelGrid>
<p:column rowspan="2" style="width:115px;">
<p:selectOneButton value="#{graph.diagramdata}" id="diagramdata">
<f:selectItem itemLabel="WAS-Diagramm" itemValue="1" />
<f:selectItem itemLabel="PSC-Diagramm" itemValue="2" />
<p:ajax listener="#{graph.changeView }" update=":options"/>
</p:selectOneButton>
<h:outputText>#{graph.diagramdata}</h:outputText>
</p:column>
<p:column rendered="#{graph.diagramdata eq '1' }">
...
</p:column>
</p:panelGrid>
</h:form>
EDIT : 배면 BEAN
@ManagedBean(name = "graph")
@SessionScoped
public class MyGraphBean implements Serializable {
private int diagramdata;
public void changeView(AjaxBehaviorEvent event) {
LOGGER.info(this.getDiagramData());
}
public int getDiagramdata() {
return diagramdata;
}
public void setDiagramdata(int diagramdata) {
if(diagramdata == 1 || diagramdata == 2) {
this.diagramdata = diagramdata;
}
}
}
PART OF하지만 값을 변경할 때 JSF 기간이 2 회 수행된다. 처음으로 in.getValue는 두 번째로 LOGGER에서 1 또는 2입니다. 하지만 결국 제 시간에 :이 outputText 인쇄 0 ...
테 라이프 사이클이 2 번 perfomed 왜 내가 BalusC: Debug JSF Lifecycle
를 사용하여 디버깅하려면?
다른 열을 올바르게 렌더링하려면 selectOneButton을 사용해야하는 이유는 무엇입니까?
편집 : DIRTY 솔루션
나는 내 문제에 대한 해결책을 발견 (매우 더러운!). p : ajax 구성 요소를 f : ajax로 변경했습니다. 이제 내 값은 두 번째 수명주기 단계에서 올바른 값으로 설정됩니다.
<p:selectOneButton value="#{graph.diagramdata}" id="diagramdata">
<f:selectItem itemLabel="WAS-Diagramm" itemValue="1" />
<f:selectItem itemLabel="PSC-Diagramm" itemValue="2" />
<f:ajax listener="#{graph.changeView }" render="options"/>
</p:selectOneButton>
또한 "0"이 설정되지 않도록 설정 메소드에서 if 문을 추가했습니다.
이제 첫 번째 jsf주기는 아무 것도 수행하지 않으며 두 번째 jsf는 내 값을 설정합니다.
의미가 있습니다,하지만 아주 좋은 것입니다 ...
backing bean을 더 게시 할 수 있습니까? 예를 들어 in.getValue를 참조하지만 여기에 해당 코드를 게시하지 않았습니다. – Catfish
backing bean의 부분을 추가했습니다. – veote