JSF - 为什么制定者不叫这个时间呢? [英] JSF - Why setter is not called this time?

查看:123
本文介绍了JSF - 为什么制定者不叫这个时间呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

和往常一样,我通过使用一个请求范围的bean一些Ajax调用已经有些麻烦。

As usual, i've some trouble by using some ajax call on a requested scoped bean.

我有这个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); trougth# {articlesSelector.articleList} 这就是所谓的我每次点击图片)。那么,这是怎么回事这个时候?

The order value is always 1. Seems that setter method is not called. This time is not a render fault, because that action is rendered on Apply request and Update model phases (in fact, System.out.println("ORDER = "+this.order); trougth #{articlesSelector.articleList} it's called every time i click on the image). So, what's up this time?

请求范围让我有点紧张:)

Request Scope make me a bit nervous :)

感谢

推荐答案

F:AJAX 应该在事件解雇=动作,不是事件=点击

<分> 是的,我知道,我在你的问题使用的评论曾建议点击,但我显然是错误的™。对不起,我认为:)

Yes, I know that I ever suggested in a comment of your question to use click, but I was apparently Wrong™. Sorry for that :)

这篇关于JSF - 为什么制定者不叫这个时间呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆