在一个包含组合组件的ui:repeat中,为commandLink设置setPropertyActionListener。

3

I've created a composite component that has a commandLink embedded inside of a ui:repeat. I need to be able to dynamically change the method that is called via the commandLink's action property but it doesn't seem to be possible due to the fact that you need to specify the ID of the commandLink in the

Since the commandLinks are in a UI:repeat, they all have a dynamic ID.

As a workaround, I'm trying to use setPropertyActionListener on the command link. However, it doesn't look like the method is ever being called. Am I missing something? Is this the wrong way to go about what I want?

Here is some sample code.

Composite Component:

<ui:repeat value="#{cc.attributes.value}" var="aUser">
<li class="ui-widget-content ui-state-default q-userListResult">   
        <p:commandLink 
        styleClass="q-userList-resultLink"
                update=":userList:q-userList-formUsers:userToolTip">
                <f:setPropertyActionListener value="{aUser}" target="#{cc.attributes.resultLinkActionListener}"/>

Using Page:

<q:userList id="userList" 
   value="#{caseWizardBackingBean.companyContacts}" 
   renderHeader="false" 
   resultLinkActionListener="#{caseWizardBackingBean.selectedCompanyContact}"/>

Bean:

private CTProfile selectedCompanyContact;
public CTProfile getSelectedCompanyContact() { return this.selectedCompanyContact; }
public void setSelectedCompanyContact(CallTrackProfile ctp) { this.selectedCompanyContact = ctp; }    

I tried adding some debug statements and breakpoints into the property's getter and setter but they are never hit. I'm guessing something odd is happening because all of the examples I can find show that this should work (but they don't use a composite component).

I should point out, I'm using the Primefaces commandLink but this seems to happen with the regular commandLink too.

1个回答

0

好的,据我所知,在当前版本的JSF(2.1.3)中无法完成此操作。

为了解决这个问题,我将组件设置为单个commandLink,然后在使用页面上使用ui:repeat,并将commandLink放在其中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接