commandLink in menuitem

UI Components for JSF
Post Reply
patbuck
Posts: 15
Joined: 20 Aug 2010, 21:46

20 Aug 2010, 23:13

If I put command links in menu items, the first commandLink (regardless if it is in the first menu item or not) is rendered without indentation and underlined. I have tried with both the default theme and redmond to see if it was a CSS issue with the default theme.

Example:

Code: Select all

<h:form>
    <p:menu style="width:180px">
        <p:submenu label="title">
            <p:menuitem>
                <h:commandLink action="/jsf/action1" value="label1"/>
            </p:menuitem>
            <p:menuitem>
                <h:commandLink action="/jsf/action2" value="label2"/>
            </p:menuitem>
            <p:menuitem>
                <h:commandLink action="/jsf/action3" value="label3"/>
            </p:menuitem>
        </p:submenu>
    </p:menu>
</h:form>
Cheers,
Patrik

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

21 Aug 2010, 01:26

You don't need a commandLink in menuitem since menuitems are commandLinks, this should be rewritten as;

Code: Select all

<p:menu style="width:180px">
        <p:submenu label="title">
            <p:menuitem action="/jsf/action1" value="label1" ajax="true|false"/>
            ...
        </p:submenu>
    </p:menu>
If you are just tring to navigate, no need to use JSF's navigation rules, you can just use url attribute of menuitem, with that you can navigate with a get request.

patbuck
Posts: 15
Joined: 20 Aug 2010, 21:46

21 Aug 2010, 10:19

That was actually the first thing I tried, but I didn't get it to work. I was under a lot of preasure with no time to sleep, so I might have forgotten ajax="false" at that time. Embedding commandLinks was something I read in a forum post that I can't seem to find again.

Anyway, it works fine now. Thanks for the help!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

21 Aug 2010, 12:29

Glad it works.

NMLokman
Posts: 2
Joined: 07 Jun 2018, 05:06

07 Jun 2018, 05:14

Hi I am trying to populate the menuitems from the bean as such

Code: Select all

<p:commandButton id="mnuItm5" styleClass="add-deal-btn" value="add deal"/>
<h:form>
	<p:menu trigger="mnuItm5" my="top" at="bottom" styleClass="add-deal-btn">
		<c:forEach items="#{templateBacking.menuItems}" var="menuItem">
			<p:menuitem action="#{templateBacking.redirectPage('views/placement-deal.jsf')}" value="#{menuItem}" ajax="true" styleClass="add-deal-btn"/>
		</c:forEach>
	</p:menu>
</h:form>
However, the action is not fired when I click on the menuitem and the backing bean is not even accessed by the action. May I know how do I fix this ?

p:s: If it helps, the url of the page changes by having an "#" at the end, but nothing happens.

Thank you.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests