像往常一樣,我對請求的scoped bean使用了一些ajax調用有些麻煩。JSF - 這次爲什麼沒有調用setter?
我有這個bean:
@ManagedBean
@RequestScoped
public class ArticlesSelector implements Serializable {
@ManagedProperty(value="#{param.type}")
private String type;
private String zone;
private String order;
@PostConstruct
public void init() {
if(type==null || type.trim().isEmpty()) { this.type="1"; }
if(zone==null || zone.trim().isEmpty()) { this.zone="list"; }
if(order==null || order.trim().isEmpty()) { this.order="1"; }
}
public String getType() { return type; }
public void setType(String type) { this.type = type; }
public String getZone() { return zone; }
public void setZone(String zone) { this.zone=zone; }
public String getOrder() { return order; }
public void setOrder(String order) { this.order = order; }
public ArrayList<String[]> getArticleList() {
...
System.out.println("ORDER = "+this.order);
...
}
}
當我做這個調用:
<h:panelGroup layout="block" id="articlesContent">
<h:form id="formArticles">
<h:outputScript name="jsf.js" library="javax.faces" target="head" />
<h:panelGroup rendered="#{articlesSelector.zone=='list'}">
<h:panelGroup layout="block" id="articlesContentList">
<h:commandLink>
<f:setPropertyActionListener target="#{articlesSelector.order}" value="2" />
<f:ajax event="click" render=":articlesContent"/>
<h:graphicImage value="img/arrow_down.png" alt="Arrow Down"/>
</h:commandLink>
<h:outputLabel value="#{articlesSelector.articleList}" />
</h:panelGroup>
</h:panelGroup>
</h:form>
</h:panelGroup>
順序值始終1
。似乎沒有調用setter方法。此時不是渲染錯誤,因爲該動作呈現在應用請求和更新模型階段(實際上,System.out.println("ORDER = "+this.order);
麻煩#{articlesSelector.articleList}
它每次我點擊圖像時都會被調用)。那麼,這次呢?
請求範圍讓我有點緊張:)
感謝
不知道這可以工作。我試過了。但`commandbutton`進入`articlesContentList`,我需要呈現`articlesContent`。這就是爲什麼我把`:` – markzzz 2010-12-02 16:01:12
是的,其實我只能寫`render =「articlesContentList」`,但問題仍然發生:) – markzzz 2010-12-02 16:07:39