1

Here is code:

<ui:repeat var="entity" varStatus="status" value="#{myentityListView.someList}">

                <h:form>
                <h:commandLink  value="Go!" action="mypage.xhtml" >
                <c:if test="#{entity.entityType=='Comment'}"><f:param  name="productId" value="#{entity.product.getId()}"/></c:if>
                <f:param  name="userId" value="#{entity.user.getId()}"/>
                </h:commandLink>
                 </h:form>

                </ui:repeat>

Maybe its cause is that h:commandLink is in ui:repeat.

mypage.xhtml is an exixting page.

Thanks

merveotesi
  • 2,145
  • 15
  • 53
  • 84
  • possible duplicate of [h:commandLink / h:commandButton is not being invoked](http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked). I by the way suggest to just use `` instead. – BalusC Jan 06 '12 at 14:12
  • thanks @BalusC but they are in different h:form s, tried your answer, did not work – merveotesi Jan 06 '12 at 14:20
  • Point 4 of that answer applies as good. – BalusC Jan 06 '12 at 14:26
  • I posted an answer anyway, this way I can show the proper approach. – BalusC Jan 06 '12 at 14:32

1 Answers1

1

You need to make sure that #{myentityListView.someList} returns exactly the same value during the form submit request as it was during the request of displaying the page. Putting the bean in the view scope (just mark it @ViewScoped) and ensuring that you preserve the list during (post)constructor or in an action method should fix it.

See also:

However, in your particular case, it's much better to just use <h:link> instead as you don't seem to need to send a POST request at all. This way you end up with nice bookmarkable and searchbot-chipherable links.

<ui:repeat var="entity" varStatus="status" value="#{myentityListView.someList}">
    <h:form>
        <h:link value="Go!" outcome="mypage.xhtml">
            <f:param name="userId" value="#{entity.user.id}" />
            <f:param name="productId" value="#{entity.product.id}" disable="#{entity.entityType != 'Comment'}" />
        </h:link>
    </h:form>
</ui:repeat>

Also note that I fixed your <c:if> approach by removing it as it won't work as you'd expect. It would always evaluate false. See also JSTL in JSF2 Facelets... makes sense?

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555