我正在从JSF1.2升级到JSF2,并将RichFaces3.3升级到4。我已经尝试了JSF2的不同版本(2.02、2.06等),但都给出了相同的错误。
我得到了下面的错误,它已经困扰了我几个小时了!
SEVERE: Error Rendering View[/my-testfile.xhtml]
javax.el.PropertyNotFoundException: /templates/components-navigation.xhtml @31,54 rendered="#{component.allowed}": Property 'allowed' not found on type org.richfaces.component.UIRepeat/templates/components-navigation.xhtml
<a4j:outputPanel rendered="#{loginBean.loggedIn}">
<a4j:repeat var="menugroup" value="#{componentNavigator.groups}">
<a4j:region rendered="#{menugroup.itemCount > 0}">
<div class="panel_menu">
<table class="title" border="0" width="100%">
<tr>
<td>
<h:outputText class="text" value="#{messages[menugroup.id]}" />
</td>
</tr>
</table>
<table class="links" border="0" width="100%">
<tbody>
<a4j:repeat var="component" value="#{componentNavigator.components}">
<a4j:region rendered="#{component.allowed}">
<a4j:region rendered="#{component.groupId == menugroup.id}">
<tr class="#{component.current?'active':'unactive'}">
<td> </td>
<td class="text" width="100%">
<h:commandLink action="#{component.getCommandAction}" actionListener="#{componentNavigator.initControllerBean}">
<span style="display:block;">
#{messages[component.id]}
</span>
<f:attribute name="controllerBean" value="#{component.controllerBean}" />
<f:setPropertyActionListener target="#{componentNavigator.currentComponent}" value="#{component}" />
</h:commandLink>
</td>
</tr>
</a4j:region>
</a4j:region>
</a4j:repeat>
</tbody>
</table>
</div>
</a4j:region>
</a4j:repeat>
</a4j:outputPanel>第31行是:
<a4j:region rendered="#{component.allowed}">你知道为什么没找到财产吗?repeat组件是否存在已知问题?
发布于 2011-09-13 21:05:07
#{component}是一个保留的隐式EL对象,它引用当前的JSF组件。它的使用方法如下:
<h:inputText value="#{bean.value}" styleClass="#{component.valid ? 'ok' : 'error'}" />在上面的示例中,#{component}解析为一个表示当前<h:inputText>的UIInput实例,该实例又具有一个isValid()方法。在提交时,当组件出现验证错误时,将设置error样式类(例如,可能具有略带红色的背景色),否则将设置ok样式类。它就像JavaScript中的this。
你应该给你的作用域变量一个不同的名字。Do not在JSF中使用以下保留EL对象之一的名称:
#{component} -当前UIComponent#{facesContext} -当前FacesContext#{request} -当前HttpServletRequest#{session} -当前HttpSession#{application} - ServletContext#{cc} -当前composite component#{param} -当前request parameter map#{paramValues} -当前request parameter values map#{requestScope} -当前request attribute map#{viewScope} -当前view attribute mapH251session attribute map#{applicationScope} - /code>#{sessionScope} - the application attribute map#{header} - the current request header map#{cookie} - the current request cookie map发布于 2011-09-13 17:03:47
您的“组件”bean需要一个
public boolean getAllowed() {
return this.allowed;
}和
public void setAllowed(boolean allowed) {
this.allowed = allowed;
}方法。属性是bean中的一个字段,它需要一个公共的getter和setter方法。大多数IDE都支持生成这些方法,比如"Source --> Generate Getter and Setter“。
另一种可能是直接调用方法。像这样,
<a4j:region rendered="#{component.isAllowed()}">使用bean代码
public boolean isAllowed() {
return this.allowed;
}如果您已经在您的componentNavigator bean中使用了getter和setter,那么如果您可以将其发布到此处(或其中的一部分),将会非常有用。
理查德
发布于 2011-09-13 20:32:00
我改变了:
<a4j:repeat var="component" value="#{componentNavigator.components}">至:
<a4j:repeat var="myComponent" value="#{componentNavigator.components}">现在一切都好了:)
我偶然发现了这个问题,它给了我线索:
https://stackoverflow.com/questions/7398526
复制相似问题