2015-05-15 28 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>