【问题标题】:invoke method of @facescomponent of composite component复合组件的@facescomponent调用方法
【发布时间】:2014-05-23 08:53:32
【问题描述】:

我需要调用复合组件的支持组件(@facescomponent)的方法。我在文章中看到其他人这样做,但没有一个对我有用。

这是我调用的方式:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite">

<cc:interface componentType="formField"/>

<cc:implementation>
    <h:commandButton value="doIt" action="#{cc.myAction}" ></h:commandButton>
</cc:implementation>
</ui:component>

这是支持组件。

@FacesComponent("formField")
public class Field extends UICommand implements NamingContainer {

public Field() {
}

@Override
public String getFamily() {
    return UINamingContainer.COMPONENT_FAMILY;
}
public String myAction() {

    System.out.println("in action");//not printed
    return null;
}
}

不应该调用myAction 方法吗?我做错了什么?

【问题讨论】:

  • 我使用了上面提到的您的代码并稍作更正,它在我的服务器日志中打印出in action 值。我在 Apache Tomcat 8.0.9 上使用了 JSF 2.2。我没有看到错误。你有任何进一步的信息吗?
  • 好吧,那是以前的安装。我什至不记得那个代码发生了什么。还是谢谢你的回复。

标签: jsf composite-component backing-beans


【解决方案1】:

你调用属性,方法需要使用: action="#{cc.myAction()}"

【讨论】:

    猜你喜欢
    • 2014-01-23
    • 2015-12-20
    • 2011-12-14
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    • 2012-10-15
    • 2018-06-24
    • 1970-01-01
    相关资源
    最近更新 更多