2015-05-15 27 views
0

我正在开发一个jsf web应用程序,我想通过正常的href url从托管bean中调用一个方法。我的问题是我与应用程序链接发送电子邮件一样如何直接从正常的href链接调用托管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. 

一些参数,我需要通过管理bean的方法时,参数值网址加载在浏览器中,任何人都可以帮助我继续下去。

回答

0

有一个示例如何获取托管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>