简体   繁体   English

如何生成动态Rich:panelMenu?

[英]how to generate dynamic rich:panelMenu?

i have a problem to generate dynamic menu, i'm using JSF1.2. 我在生成动态菜单时遇到问题,我正在使用JSF1.2。 I tried the c:forEach with an arrayList to generate dynamic rich:panelMenu as BalusC advised in a related forum, but get Accessor never triggered in c:forEach. 我尝试了用arrayList生成c:forEach,以生成BalusC在相关论坛中建议的动态rich:panelMenu,但是getor从未在c:forEach中触发。 it ruined me a day. 它毁了我一天。 can anyone provide me a solution ? 谁能给我解决方案?

 <c:forEach items="#{serviceListBean.services}" var="child">
              <rich:panelMenuItem mode="none">                  
                  <h:outputText value="#{child.serviceId}"></h:outputText>                                          
              </rich:panelMenuItem>
            </c:forEach>

what's wrong in this code? 这段代码有什么问题? can anyone enlighten me?. 谁能启发我? For info, serviceListBean is request scoped bean. 对于信息,serviceListBean是请求范围的bean。

Two possible causes: 两种可能的原因:

  1. JSTL is not declared as taglib in JSP or Facelets. JSTL在JSP或Facelets中未声明为taglib。 To confirm this, rightclick page in browser and choose View Source . 要确认这一点,请在浏览器中右键单击页面,然后选择“ 查看源代码” Do you see <c:forEach> tag unparsed among the generated HTML? 您是否在生成的HTML中看到未解析的<c:forEach>标记? If you're using JSP, declare it as follows: 如果您使用的是JSP,请按以下说明进行声明:

     <%@taglib prefic="c" uri="http://java.sun.com/jsp/jstl/core" %> 

    Or if you're using Facelets, declare it as follows in root element: 或者,如果您使用的是Facelets,请在根元素中声明如下:

     xmlns:c="http://java.sun.com/jsp/jstl/core" 

    On some servers like Tomcat, which doesn't ship with JSTL out the box, you would also need to install JSTL first, see also this info page . 在Tomcat等未附带JSTL的服务器上,还需要先安装JSTL,另请参阅此信息页面

  2. This piece of code is in turn been placed inside a JSF repeating component, like <h:dataTable> with a var="serviceListBean" . 这段代码又被放置在JSF重复组件内,例如<h:dataTable>var="serviceListBean" This is also not going to work. 这也行不通。 You would need to replace the JSF repeating component by <c:forEach> as well. 您还需要用<c:forEach>替换JSF重复组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM