2012-09-05 4 views
0

jsf 템플릿 페이지가 있습니다. 이 템플릿에서는 매개 변수와 함께 구성 요소를 사용하고 싶습니다. 사실 나는 수집을 반복하고 싶습니다. 이 컬렉션은 특정 페이지의 매개 변수에 의해 결정되어야합니다. 매개 변수 이름은 selectedMenu입니다. 어떻게하면 콩에서 이것을 사용할 수 있습니까?jsf2 매개 변수가있는 템플릿 구성 요소

<div id="notes"> 
        selectedMenu: #{selectedMenu} 
        <h:form> 
         <h:inputHidden value="#{notatkaController.searchForm.kategoria}"> 
          <f:param value="#{selectedMenu}" /> 
         </h:inputHidden> 
         <ui:repeat value="#{notatkaController.items}" var="item" varStatus="iter"> 
          <f:param value="#{selectedMenu}" /> 
          <p class="q-title"><strong><h:outputText value="#{item.ntaData}" /></strong></p> 
          <p class="answer"><h:outputText value="#{item.ntaDane}" escape="false" /></p>          
         </ui:repeat> 
         <span>Moje notatki</span> 
         <textarea>Tu wpisz treść swojej notatki</textarea> 
         <span>[+] dodaj notatkę</span> 
        </h:form> 
       </div> 

내 콩 :

@ManagedBean(name = "notatkaController") 
@ViewScoped 
public class NotatkaController extends AbstractController<Notatka> implements Serializable { 

@EJB 
private pl.alfaprojekt.model.session.NotatkaFacade ejbFacade; 
private NotatkaSearchForm searchForm; 

public DataModel getItems() { 
    if (items == null) 
     items = getPagination().createPageDataModel(); 
    return items; 
} 

public PaginationHelper getPagination() { 
    if (pagination == null) { 
     if (paginationSize == null) 
      paginationSize = 10; 
     pagination = new PaginationHelper(paginationSize) { 

      @Override 
      public int getItemsCount() { 
       return getFacade().countByParam(getSearchForm()); 
      } 

      @Override 
      public DataModel createPageDataModel() { 
       if (rapId == null) 
        return new ListDataModel(getFacade().findRangeByParam(getSearchForm(), new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()})); 
       else { 
        Long uzyId = SessionUtil.getUser().getUzyId(); 
        return new ListDataModel(convertToRaportWierszList(getFacade().findRangeByParam(getSearchForm(), new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()}), uzyId)); 
       } 
      } 
     }; 
    } 
    return pagination; 
} 

}

답변

0

제가 질문을 이해 확실하지 오전하지만 난 대답 질문은 이것이다 :

나는 동적으로 뭔가를 표시합니다. 페이지에 액세스 할 때 표시 할 내용을 지정하고 싶습니다.

보기 :

그런 다음 사용할 수있는 다음 :

<f:event listener="#{myBean.myMethod}" type="preRenderView" /> 

콩 : 매개 변수와

public void myMethod(ComponentSystemEvent event){ 
//your logic here 
} 

:

<f:metadata> 
    <f:event listener="#{myBean.myMethod}" type="preRenderView" id="fevent"/> 
    <f:attribute name="myParam" value="#{mySecondBean.param)" /> 
</f:metadata> 

그리고

public void myMethod(ComponentSystemEvent event){ 
String id = (String) event.getComponent().getAttributes().get("myParam"); 
} 
관련 문제