2010-07-21 33 views
0

我有一個通用的按鈕的jsp:傳遞JSP EL表達式或管理bean實例:包括

<wow:button id="addButton" iconClass="add16 icon16x16" 
      action="#{managedbean.addNew}" type="submit" immediate="true" 
      value="#{lblMsg.label_add }" /> 

<wow:button id="deleteButton" iconClass="iconCancel" 
      action="#{managedbean.delete}" type="submit" 
      value="#{lblMsg.label_delete }" /> 

這被通過

<wow:outputText value="#{locationBean.disclaimer}"></wow:outputText> <br /> 
<jsp:include page="buttons.jsp"> 

本頁面包含在另一個JSP頁面有一個管理bean實例由EL表達式使用。我想通過locationBean這個實例到buttons.jsp。一種方式是將jsp:include中的param值設置爲bean名稱,並在buttons.jsp中使用requestScope [beanName]。

有沒有更好的方法?

編輯:哇是我們自己的JSF組件庫。

回答

2

使用遺留的JSP,我不認爲有語義上更好的方法。如果你改變bean的範圍,你的方法可能會中斷。另一種方法可能是使用JSTL c:set代替。

<c:set var="currentBean" value="#{locationBean}" scope="request" /> 
<jsp:include page="buttons.jsp" /> 

<h:commandButton action="#{currentBean.action}" /> 

但是,這可能與另一豆具有巧合的同名衝突。

+0

明天我會試試看,併發布答案。謝謝! – Rohit 2010-07-27 03:14:48