0

Jsf file having inputtext field.After entering value in the field and pressing enter,it should perform the action in command button(nextButton) i.e- call Action() in BackingBean.java

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">

    <ui:define id="content" name="page-content">
    <h:inputText id="Number" value="#{BackinBean.Id}"/>
    </ui:define>

    <ui:define id="contentfooter" name="page-content_footer">

        <table width="100%">
            <tr>
                <td>
                    <h:commandButton id="nextButton" value="Next"
                        action="#{BackinBean.Action}" styleClass="btn"/>
                </td>
            </tr>
        </table>
    </ui:define>

Bean class-BackingBean.java has

    public Action(){..........}
shreya
  • 183
  • 1
  • 1
  • 9

2 Answers2

0

Your code has no form tag and your commandButton has no process attribute.

Study this definitive guide: Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes

J Slick
  • 929
  • 11
  • 17
0

One way to achieve this is, you will need to capture the keycode and check if it is enter event (keycode = 13 ) and trigger click event on the button you desire which will submit the form and invoke the associated backing bean action method. Please see Default action to execute when pressing enter in a form

OTM
  • 656
  • 5
  • 8