首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在类型org.richfaces.component.UIRepeat上找不到属性'xxxxxx‘

在类型org.richfaces.component.UIRepeat上找不到属性'xxxxxx‘
EN

Stack Overflow用户
提问于 2011-09-13 15:54:15
回答 3查看 3.2K关注 0票数 2

我正在从JSF1.2升级到JSF2,并将RichFaces3.3升级到4。我已经尝试了JSF2的不同版本(2.02、2.06等),但都给出了相同的错误。

我得到了下面的错误,它已经困扰了我几个小时了!

代码语言:javascript
复制
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

代码语言:javascript
复制
<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>&nbsp;</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行是:

代码语言:javascript
复制
<a4j:region rendered="#{component.allowed}">

你知道为什么没找到财产吗?repeat组件是否存在已知问题?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-09-13 21:05:07

#{component}是一个保留的隐式EL对象,它引用当前的JSF组件。它的使用方法如下:

代码语言:javascript
复制
<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
票数 1
EN

Stack Overflow用户

发布于 2011-09-13 17:03:47

您的“组件”bean需要一个

代码语言:javascript
复制
public boolean getAllowed() {
    return this.allowed;
}

代码语言:javascript
复制
public void setAllowed(boolean allowed) {
   this.allowed = allowed;
}

方法。属性是bean中的一个字段,它需要一个公共的getter和setter方法。大多数IDE都支持生成这些方法,比如"Source --> Generate Getter and Setter“。

另一种可能是直接调用方法。像这样,

代码语言:javascript
复制
<a4j:region rendered="#{component.isAllowed()}">

使用bean代码

代码语言:javascript
复制
public boolean isAllowed() {
    return this.allowed;
}

如果您已经在您的componentNavigator bean中使用了getter和setter,那么如果您可以将其发布到此处(或其中的一部分),将会非常有用。

理查德

票数 0
EN

Stack Overflow用户

发布于 2011-09-13 20:32:00

我改变了:

代码语言:javascript
复制
<a4j:repeat var="component" value="#{componentNavigator.components}">

至:

代码语言:javascript
复制
<a4j:repeat var="myComponent" value="#{componentNavigator.components}">

现在一切都好了:)

我偶然发现了这个问题,它给了我线索:

https://issues.jboss.org/browse/RF-8026

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7398526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档