Problem with p:defaultCommand

UI Components for JSF
Post Reply
sanmarco
Posts: 21
Joined: 18 Jun 2013, 13:46

25 Jun 2013, 10:46

Hi, I'm having some problem with the default command in primefaces mobile, I include a sample page to explain it.
If you open the page and then press Enter on the keyboard it executes btn1, event if I said that the default command is btn2.

Ideas?

Code: Select all

	<pm:page title="Title">
		<pm:view id="params">
				<h:form id="form">
					<p:inputText id="text">
						<p:focus for="text" />
					</p:inputText>
					<p:commandButton value="Button1" id="btn1" action="#{bean.goHome}" />
					<p:commandButton value="Button2" id="btn2" actionListener="#{bean.cleanOldSearch}" action="#{bean.search}" />
					<p:defaultCommand target="btn2" />
				</h:form>
		</pm:view>
	</pm:page>
I'm using Primefaces 3.5.7, Mobile 0.9.5 and Mojarra 2.1.23.

sanmarco
Posts: 21
Joined: 18 Jun 2013, 13:46

03 Jul 2013, 08:37

I still can't solve it, ideas?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

04 Jul 2013, 00:51

Try the following:

Code: Select all

<p:defaultCommand target=":form:btn2" />
since your form is as follows:

Code: Select all

<h:form id="form">
that's how i use defaultCommand in my app.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

ZolfriK
Posts: 1
Joined: 07 Aug 2013, 11:35

07 Aug 2013, 11:38

Hi,
I have the same problem and unfortunately the smithh's workaround does not solve it.
Any other idea?

Thanks.

StephanH
Posts: 1
Joined: 23 May 2014, 08:46

12 Jan 2015, 09:24

Hi,

had the same problem and played around a bit: Placing

Code: Select all

<p:defaultCommand target=":form:btn2" />
after all other input fields within the form at the very end solved the issue for me.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests