English 中文(简体)
在构成部分内指挥Button的通行行动
原标题:Pass actionListener method to commandButton within a component

首先,请原谅我的无知和无能为的是使用搜索引擎(一只鞋子被长期搜查,但找不到解决这一问题的任何满意答案)。

我采用了一种行动清单兼容方法:

@ManagedBean(name = "myBean")
@ViewScoped
class Bean{
    public String myAction(ActionEvent event){
        ... = event.getComponent().getAttributes().get("something");
    }
}

之后,我有这样的支部:

<composite:interface>
    <composite:attribute name="actionBean" required="true"/>
    <composite:attribute name="actionMethod" method-signature="void myAction(javax.faces.event.ActionEvent)" />
</composite:interface>
<composite:implementation>
        <h:form>
            <p:commandButton actionListener="#{cc.attrs.actionBean[cc.attrs.actionMethod]}">
                <f:attribute name="something" value="somevalue" />
            </p:commandButton>
        </h:form>
</composite:implementation>

它被称为:

<namespace:myComponent actionBean="#{myBean}" actionMethod="myAction" />

我知道,这一呼吁并不奏效,我想知道它如何正确!

我的主要意图是,我只想有一个相对通用的支架(或许可以稍后再使用),它包含一个顿子。 在点击这个纽子时,一想通过一个物体(无简单明了!) 插图一只使用action=>. > >>,并通过f:param通过。 使用<代码>Listener方法,即通过<代码>event.getComponent().getAttributes(......)接收物体。

我认为,签署<代码>避免我的行动(javax.faces.event.ActionEvent)的问题是打破相关方法与部件的关联性? 是否普遍有可能以任何理由将某些成分(如果是,如何)割裂方法?

因此,我希望有可能找到解决办法,通过改变上述战略来解决一般问题,或者可能使用某种ice和不同的东西(一般而言,不喜欢使用任何 ha子或工作环绕,而是要利用框架的意图)。

Thanks if somebody would find the time to point me the way! In case this question already exists, would be nice to get to the related post and have this deleted.

最佳回答

如下:

<namespace:myComponent myAction="#{myBean.myAction}"/>

综合构成部分:

<composite:interface>
    <composite:attribute name="myAction" 
                         required="true" 
                         method-signature="void myAction(javax.faces.event.ActionEvent)"
                         targetAttributeName="actionListener"/>
</composite:interface>
<composite:implementation>
    <h:form>
        <p:commandButton id="myAction">
            <f:attribute name="something" value="somevalue" />
        </p:commandButton>
    </h:form>
</composite:implementation>

http://docs.oracle.com/javaee/6/javaserverfaces/2.1/docs/vdldocs/facelets/composite/attribute.html 它有几种选择,可以让听众了解综合内容。 为此,我使用了<代码>targetAttributeName。

问题回答

暂无回答




相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签