Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf RichFaces 4和@ViewScope_Jsf_Richfaces - Fatal编程技术网

Jsf RichFaces 4和@ViewScope

Jsf RichFaces 4和@ViewScope,jsf,richfaces,Jsf,Richfaces,我正在从RichFaces 3.3.3迁移到4.0,遇到了一个无法解决的问题 到目前为止,我一直使用RichFaces的@KeepAlive注释来实现bean的查看范围,但新版本4到目前为止还没有这样的功能(据我所知)。所以我认为@viewscope注释将是自然(快速)的替代品,但它不起作用。 这是给我带来麻烦的相关代码。它呈现一个表,其中包含以链接形式显示姓名的客户,因此当单击姓名时,会弹出一个窗口来编辑数据。它在带有@KeepAlive的v3.3.3中工作,但在带有@ViewScoped的v

我正在从RichFaces 3.3.3迁移到4.0,遇到了一个无法解决的问题

到目前为止,我一直使用RichFaces的@KeepAlive注释来实现bean的查看范围,但新版本4到目前为止还没有这样的功能(据我所知)。所以我认为@viewscope注释将是自然(快速)的替代品,但它不起作用。 这是给我带来麻烦的相关代码。它呈现一个表,其中包含以链接形式显示姓名的客户,因此当单击姓名时,会弹出一个窗口来编辑数据。它在带有@KeepAlive的v3.3.3中工作,但在带有@ViewScoped的v4中不工作(不会调用弹出窗口)

页面:

<h:form prependId="false">
 <rich:dataTable id="table" value="#{myBean.customers}" var="customer">
    <!--...headers...-->
    <h:column>
        <a4j:commandLink action="#{myBean.selectCustomer}"
            oncomplete="#{rich:component('popup_customer_editor')}.show();" render="form_customer_editor">
            ${customer.name}
            <f:setPropertyActionListener value="#{customer}" target="#{myBean.selectedCustomer}"/>
        </a4j:commandLink>
    </h:column>
    <h:column>${customer.address}</h:column>
 </rich:dataTable>
</h:form>

<rich:popupPanel id="popup_customer_editor>
    <h:form id="form_customer_editor">
    <!--...form fields...-->
    </h:form>
</rich:popupPanel>

任何帮助都将不胜感激

您的行动可能不会被调用的原因有两个:

  • 您有一个已提交的字段,验证/转换失败。如果存在验证或转换错误,则不会调用您的操作。你应该有一个
    来确保你看到它,因为它是a4j:clickLink,所以把它放在
    a4j:outputPanel
    中,就像这样:

  • 您在另一个
    中有一个
    ,并且您正在尝试提交内部的一个。你可以很容易地用firebug跟踪这一点。出于某种原因,JSF决定什么都不做

  • 看起来你在这里做一些古怪的生意:

  • 重新渲染表单。我在JSF2中对
    进行重新排序时遇到了严重的问题(即它们停止工作),特别是使用richfaces模式面板,通过它们实现实际面板的方式使其成为可能,在
    元素中将内容从DOM中的任何位置移动。因此,我建议在表单中创建一个
    ,并重新呈现该表单
  • 。真正地您还应该有EL2,因此您可以更改此选项:

    <a4j:commandLink action="#{myBean.selectCustomer}"
        oncomplete="#{rich:component('popup_customer_editor')}.show();"
        render="form_customer_editor">
             ${customer.name}
        <f:setPropertyActionListener value="#{customer}"
            target="#{myBean.selectedCustomer}"/>
    </a4j:commandLink>
    
    
    ${customer.name}
    

  • 谢谢你的建议,但是方法是myBean。selectCustomer(customer)没有被调用。只是一个关于作用域的注释,RichFaces 4将不会有一个视图作用域(a4j:keepAlive),因为它现在可以从JSF 2中获得。有两个原因可能无法调用您的操作:1。您有一个已提交的字段,验证/转换失败。如果存在验证或转换器错误,则不会调用您的操作。您应该有一个
    ,以确保您看到它,或者在web.xml中将开发阶段设置为development(我到办公室时会给您实际的代码片段)。2.您在另一个
    中有一个
    ,您正在尝试提交内部的。你可以很容易地用firebug跟踪这一点。PS:我讨厌堆栈溢出格式。
    <a4j:commandLink action="#{myBean.selectCustomer}"
        oncomplete="#{rich:component('popup_customer_editor')}.show();"
        render="form_customer_editor">
             ${customer.name}
        <f:setPropertyActionListener value="#{customer}"
            target="#{myBean.selectedCustomer}"/>
    </a4j:commandLink>
    
    <a4j:commandLink action="#{myBean.selectCustomer(customer)}"
        oncomplete="#{rich:component('popup_customer_editor')}.show();" render="form_customer_editor" value=#{customer.name}"/>