suggestion for commandButton

UI Components for JSF
Post Reply
zsuiqiang
Posts: 146
Joined: 13 Sep 2010, 03:52

09 Nov 2010, 04:18

Sometimes we want do something and navigate to an othor page in new page.So we need "target" attribute for commandButton. We really hope you to think about it.
primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

09 Nov 2010, 12:04

Hi,

Did you really understand how JSF navigation work? Use "action" attribute of commandButton for navigation. Return value of action defines your navigation case.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

zsuiqiang
Posts: 146
Joined: 13 Sep 2010, 03:52

10 Nov 2010, 05:15

Sorry!
I do use "action" attribute of commandButton for navigation, return value of action defines your navigation case.But I want open the target view in new window.
primefaces:jakarta:12.0.0.jar,
primefaces-ext:jakarta:12.0.0.jar,
JSF Mojarra 3.0
glassfish-6.2.5,
netbeans 14
IDEA 2022.2.2
Browser: Edge

vanjadardic
Posts: 55
Joined: 08 Sep 2010, 09:18
Location: Banja Luka, Bosnia and Herzegovina
Contact:

10 Nov 2010, 13:20

You can always try to mix in some JavaScript. Here is something that might wotk. I didn't try it.

Code: Select all

<p:commandButton ...
  oncomplete="window.open('#{request.contextPath}/faces/newPage.xhtml')"/>
PrimeFaces version: whatever is the latest
Mojarra version: whatever is the latest
GlassFish & Tomcat version: whatever is the latest
Chrome & Firefox version: whatever is the latest
And a little bit of IE

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

10 Nov 2010, 14:05

Use p:button for get based navigations.

MikeK
Posts: 104
Joined: 13 Oct 2010, 15:07

13 Dec 2010, 16:59

I know this thread is a little old but I was having the same problem. My solution is below in case it helps anyone. Setting target="_blank" on the form will open a new window with p:commandButton.

Code: Select all

 <h:form target="_blank">  
               <p:commandButton value="Run Report" action="#{reportBean.runReport}" ajax="false" />
            </h:form>
Prime Faces 6.2
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests