【问题标题】:How to call managed bean method or class directly from normal href link? [duplicate]如何直接从普通的 href 链接调用托管 bean 方法或类? [复制]
【发布时间】:2015-07-27 01:04:59
【问题描述】:

我正在开发一个 jsf Web 应用程序,我想通过普通的 href url 从托管 bean 调用一个方法。我的问题是我正在发送一封电子邮件,其中包含应用程序链接,例如

http://192.168.1.10/app/password.xhtml

我已经附加了一些参数,例如

http://192.168.1.10/app/password.xhtml?no=DBzMMeIE7SY=

I need to get the request parameter "no" as "DBzMMeIE7SY=" and the method of managed bean class PasswordBean.java with change() method should be called where i can  get the parameters through request. I have given the initialize method also init method it is not called.

当url在浏览器中加载时我需要通过托管bean方法的参数值,任何人都可以帮助我继续它。

【问题讨论】:

    标签: jsf href


    【解决方案1】:

    有示例如何在托管 bean 中获取请求参数。

    Bean 实现:

    @ManagedBean
    @ViewScoped
    public class PasswordBean {
    
    private String no;
    
    
        public void init() {
            if (!FacesContext.getCurrentInstance().isPostback()) {
                if (!StringUtils.isEmpty(no)) {
                    // do some actions
                }
            }
        }}
    

    在password.xhtml里面:

        <f:metadata>
            <f:viewParam name="no" value="#{passwordBean.no}" />
            <f:event type="preRenderView" listener="#{passwordBean.init}" />
        </f:metadata>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-09
      • 1970-01-01
      • 2012-03-26
      • 2012-06-19
      • 2014-11-29
      • 2013-01-24
      • 1970-01-01
      • 2022-01-21
      相关资源
      最近更新 更多