JSF复合组件< F:AJAX>包含未知的id - 找不到它在组件的上下文中 [英] JSF Composite component <f:ajax> contains an unknown id - cannot locate it in the context of the component

查看:204
本文介绍了JSF复合组件< F:AJAX>包含未知的id - 找不到它在组件的上下文中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用更新从复合组件事件父组件 F:AJAX

复合组件是在这里:

 < CC:接口>
    < CC:属性名=更新/>
    < CC:属性名=customid要求=真/>
    < CC:属性名=val的要求=真/>
    < CC:属性名=的SelectedValue要求=真/>
< / CC:接口>
< CC:实施>
    < H:panelGrid的列=2的风格=字体大小:10px的>
        <电话号码:selectOneMenu用于ID =#{cc.attrs.customid}值=#{cc.attrs.selectedvalue}>
            < F:selectItems的值=#{cc.attrs.val}/>
            < F:Ajax事件=变渲染=#{cc.attrs.update/>
        < / P:selectOneMenu用于>
        <电话号码:的commandButton型=按钮图标=UI图标加的onclick =dlg.show(); />
    < / H:panelGrid的>
< / CC:实施>
 

现在使用该组件时,如下:

 < H:形式GT;
    < EZ:组合customid =使VAL =#{vehicleBean.makes}的SelectedValue =#vehicleBean.vehicle.make}更新=模式/>
    <电话号码:selectOneMenu用于ID =模型VALUE =#{vehicleBean.vehicle.model}>
        < F:selectItems的值=#{vehicleBean.models}/>
    < / P:selectOneMenu用于>
< /小时:形式GT;
 

我收到以下错误:

包含未知的ID模式 - 无法找到它的成分化妆的情况下

解决方案

由于更新组件就是你必须解决它以不同的方式,并抄送之外。首先给你形成一个ID:

 < H:格式ID =MyForm的>
 

然后从你的CC是这样解决的目标组件

 渲染=:MyForm的:模式
 

请注意,结尾的冒号,它可以让JSF搜索属性的文档根目录。

I'm trying to update a parent component from a composite component event using f:ajax.

The composite component is here:

<cc:interface>
    <cc:attribute name="update" />
    <cc:attribute name="customid" required="true"/>
    <cc:attribute name="val" required="true"/>
    <cc:attribute name="selectedvalue" required="true"/>
</cc:interface>
<cc:implementation>
    <h:panelGrid columns="2" style="font-size: 10px" >
        <p:selectOneMenu id="#{cc.attrs.customid} value="#{cc.attrs.selectedvalue}">
            <f:selectItems value="#{cc.attrs.val}"/>
            <f:ajax event="change" render="#{cc.attrs.update" />
        </p:selectOneMenu>
        <p:commandButton type="button" icon="ui-icon-plus" onclick="dlg.show();" />
    </h:panelGrid>
</cc:implementation>

Now when using this component as follows:

<h:form>
    <ez:combo customid="make" val="#{vehicleBean.makes}" selectedvalue="#vehicleBean.vehicle.make}" update="model"  />
    <p:selectOneMenu id="model" value="#{vehicleBean.vehicle.model}">
        <f:selectItems value="#{vehicleBean.models}" />
    </p:selectOneMenu>
</h:form>

I get the following error:

contains an unknown id 'model' - cannot locate it in the context of the component make

解决方案

Since the component to update is outside the cc you have to address it in a different way. First give your form an id:

<h:form id="myform">

Then address the target component from your cc like this:

render=":myform:model"

Notice the trailing colon which lets JSF search the attribute from the document root.

这篇关于JSF复合组件&LT; F:AJAX&GT;包含未知的id - 找不到它在组件的上下文中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆