0

I want to use other primefaces components in p:menuitem. Components display in page but actionlistener doesn't work and inputtext's value doesn't push to bean's value1 attribute. Is there any way to handle this problem?

<p:commandButton id="dynaButton" value="Search" type="button" icon="ui-icon-extlink"/>
<p:slideMenu overlay="true" trigger="dynaButton" my="left top" at="left bottom" style="width:180px">
    <p:submenu label="Search">
        <p:menuitem>
            <p:outputLabel value="Search by Id" />
            <p:inputText value="#{bean.value1}" />
            <p:commandButton value="save" actionListener="#{bean.method1}"  />
        </p:menuitem>
    </p:submenu>
    <p:submenu label="Search By Product">
        <p:menuitem value="Delete"  ajax="false" icon="ui-icon-close"/>
    </p:submenu>
    <p:submenu label="Location" icon="ui-icon-extlink">
        <p:submenu label="Prime Links">
            <p:menuitem value="Prime" url="http://www.prime.com.tr" />
            <p:menuitem value="PrimeFaces" url="http://www.primefaces.org" />
        </p:submenu>
        <p:menuitem value="Mobile" />
    </p:submenu>
</p:slideMenu>
karlkeller
  • 1,251
  • 3
  • 12
  • 22

2 Answers2

0

Try change your code to the following:

        <p:menuitem>
            <p:outputLabel value="Search by Id" />
            <p:inputText id="inputField" value="#{bean.value1}" />
            <p:commandButton process="inputField @this" value="save" actionListener="#{bean.method1}"  />
        </p:menuitem>

Check these answers too:

Why to add process=“@this” explicitly to p:commandButton to get action invoked?

Understanding process and update attributes of PrimeFaces

Community
  • 1
  • 1
Anatoly
  • 5,056
  • 9
  • 62
  • 136
  • thank you for your answer. After this change actionlistener works, but value is always null. its value doesn't push to bean. – karlkeller Jan 09 '15 at 08:28
0

You miss the update attribute.

Note that menuitems can be directly processed, but cannot be directly updated, you need to update the entire menu

<p:slideMenu id="menu" ...>
    <p:submenu label="Search">
        <p:menuitem id="item">
            <p:outputLabel value="Search by Id" />
            <p:inputText value="#{bean.value1}" />
            <p:commandButton value="save" actionListener="#{bean.method1}" process="item" update="menu" />
            <h:outputText value="#{bean.value1}" />
        </p:menuitem>
    </p:submenu>
</p:slideMenu>
Michele Mariotti
  • 7,372
  • 5
  • 41
  • 73