属性“xxxxxx”在 org.richfaces.component.UIRepeat 类型上找不到

发布于 2024-12-04 10:08:51 字数 3060 浏览 0 评论 0原文

我将从 JSF 1.2 升级到 JSF 2,从 Richfaces 3.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>&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 行是:

<a4j:region rendered="#{component.allowed}">

有什么想法为什么没有找到该属性吗?重复组件是否存在已知问题?

I'm upgrading from JSF 1.2 to JSF 2 and Richfaces 3.3 to 4.
I've tried various version of JSF2 (2.02, 2.06, etc) and all give the same error.

I'm getting the following error that has been hurting my head for hours now!

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>

Line 31 is:

<a4j:region rendered="#{component.allowed}">

Any ideas why the property is not been found? Is there a know issue with the repeat component?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

记忆里有你的影子 2024-12-11 10:08:52

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

<h:inputText value="#{bean.value}" styleClass="#{component.valid ? 'ok' : 'error'}" />

在上面的示例中,#{component} 解析为 UIInput 实例表示当前 ,该实例又具有isValid() 方法。提交后,当组件出现验证错误时,将设置 error 样式类(例如可能具有微红色背景色),否则将设置 ok 样式类被设置。就像 JavaScript 中的 this 一样。

您应该为作用域变量指定不同的名称。不要不要在 JSF 中使用以下保留 EL 对象之一的名称:

#{component} is a reserved and implicit EL object which refers to the current JSF component. It can be used as follows:

<h:inputText value="#{bean.value}" styleClass="#{component.valid ? 'ok' : 'error'}" />

In the above example, the #{component} resolves to an UIInput instance representing the current <h:inputText>, which in turn has a isValid() method. Upon submit, when the component has a validation error, the error style class will be set (which may have for example a reddish background color), else the ok style class will be set. It's like as this in JavaScript.

You should give your scoped variables a different name. Do not use the name of one of the following reserved EL objects in JSF:

烈酒灼喉 2024-12-11 10:08:52

您的“组件”bean 需要一个

public boolean getAllowed() {
    return this.allowed;
}

and

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,那么如果您可以将其发布到此处(或其中的一部分),那么将会很有用。

理查德

Your 'component' bean needs a

public boolean getAllowed() {
    return this.allowed;
}

and

public void setAllowed(boolean allowed) {
   this.allowed = allowed;
}

method. A property is a field in your bean, which needs a public getter and setter method. Most IDEs support generating those methods look out for something like "Source --> Generate Getter and Setter".

Another possibility would be to call a method directly. Something like,

<a4j:region rendered="#{component.isAllowed()}">

with a bean code

public boolean isAllowed() {
    return this.allowed;
}

If you've already getter and setter in your componentNavigator bean it would be usefull if you could post it here (or parts of it).

Richard

盗心人 2024-12-11 10:08:52

我将:更改

<a4j:repeat var="component" value="#{componentNavigator.components}">

为:

<a4j:repeat var="myComponent" value="#{componentNavigator.components}">

,现在一切都很好了:)

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

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

I changed:

<a4j:repeat var="component" value="#{componentNavigator.components}">

to:

<a4j:repeat var="myComponent" value="#{componentNavigator.components}">

and it's all good now :)

I stumbled across this issue which gave me the clue:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文