无法从复合组件中找到匹配的导航案例 [英] Unable to find matching navigation case from composite component

查看:127
本文介绍了无法从复合组件中找到匹配的导航案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复合组件按钮,操作来自一个属性。

I have a composite component button and the action is coming from an attribute.

<comp:interface>
    <comp:attribute name="buttonId" required="false"/>
    <comp:attribute name="action" required="false" method-signature="java.lang.String action()"/>
    <comp:attribute name="alt"/>
    <comp:attribute name="value" />
    <comp:attribute name="immediate"/>
</comp:interface>

<comp:implementation>
    <h:commandButton alt="#{cc.attrs.alt}" action="#{cc.attrs.action}"
                     value="#{cc.attrs.value}"  id="#{cc.attrs.buttonId}"
                     immediate="#{cc.attrs.immediate}"/>
</comp:implementation>

当我创建按钮时,操作来自我的控制器。

When I create the button the action comes from my controller.

<test:myButton value="Test" alt="test" action="{myController.doSomething}" immediate="true" buttonId="testId"/> 

然后我有一个导航规则,查找 myController.doSomething

I then have a navigation rule that looks for myController.doSomething

<navigation-case>
        <from-action>#{myController.doSomething}</from-action>
        <from-outcome>success</from-outcome>
        <to-view-id>/pages/test1.xhtml</to-view-id>
        <redirect />
 </navigation-case>

问题是当我点击按钮时动作来自#{cc.attrs.action所以我收到以下错误

The problem is when I click on the button the action is coming from #{cc.attrs.action} so I get the following error

Unable to find matching navigation case with from-view-id '/pages/test.xhtml' for action '#{cc.attrs.action}' with outcome 'success'

我怎么能绕过这个?

推荐答案

添加targets属性以将action属性重新定位到commandButton将解决此问题。然后在commandButton上不需要action属性。

Adding the targets attribute to re-target the action attribute to the commandButton will resolve the issue. The action attribute is then not necessary on the commandButton.

<comp:interface>
    <comp:attribute name="buttonId"/>
    <comp:attribute name="action" targets="#{cc.attrs.buttonId}" method-signature="java.lang.String action()"/>
    <comp:attribute name="alt"/>
    <comp:attribute name="value" />
    <comp:attribute name="immediate"/>
</comp:interface>

<comp:implementation>
    <h:commandButton alt="#{cc.attrs.alt}" 
                     value="#{cc.attrs.value}"  id="#{cc.attrs.buttonId}"
                     immediate="#{cc.attrs.immediate}"/>
</comp:implementation>

http://www.devmanuals.com/tutorials/java/jsf/jsf2TagLibrary/composite/attribute.html


目标:这是一个必需属性,它指定
的目标通过
'method-signature'属性调用组件客户端ID(如果存在) )。不同的目标客户端
ID可以用目标列表中的空格(不是制表符空格)分隔,但是,如果
此属性不与此标记一起使用,则使用属性
method-signature只有'name'属性的值是
目标,或者可以说'name'属性的唯一值是目标。

targets : This is a required attribute that specifies the target to invoke the component client ids of by the 'method-signature' attribute (if present). Different target client ids can be separated by a space (not tab space) in target list but, if this attribute is not used with this tag and the attribute method-signature is used then only the value of 'name' attribute is targeted or can say the only value of 'name' attribute is targeted.

您还可以使用以下链接中targetAttributeName属性文档中描述的方法。基本上你会将 cc:attribute 的名称与commandButton id相同,然后使用 targetAttributeName =action说你正在重新定位commandButton动作属性。

You can also use the method described under the targetAttributeName attribute documentation from the link below. Basically you would have the name of the cc:attribute be the same as the commandButton id and then use targetAttributeName="action" to say that you are re-targeting for the commandButton action attribute.

http://docs.oracle.com/javaee/6/javaserverfaces/2.1/docs/vdldocs/facelets/composite/attribute。 html

这篇关于无法从复合组件中找到匹配的导航案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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