p:commandButton ignores returned String from bean

UI Components for JSF
Post Reply
honyk
Posts: 150
Joined: 28 Sep 2010, 11:14

09 Apr 2011, 07:56

Hello Everyone,

when the following code is used:

Code: Select all

<h:commandButton value="#{i18n.generate}" action="#{renderBean.render()}"/>
the user is redirected to the new page as it is returned as String from that bean method (render).

Code: Select all

public String render() throws Exception {
  // ...
        return "mypage";
    }
If I replace this component with p:commandButton, although the render method is executed, the returned value is ignored and the original form is not redirected to the specified page. I don't see any error in the log. I just want to skin this component...
Does this component require another settings to get the same bahaviour?

Regards,
Jan

_________
Tomcat/Mojarra 2.0.4/PF 3.0 Snapshot (11-04-07).

robert.m
Posts: 226
Joined: 07 Dec 2010, 22:52
Location: Salzburg/Austria

09 Apr 2011, 12:04

You could try to set ajax="false" and also remove the brackets from your action-attribute (action="#{renderBean.render}" instead of action="#{renderBean.render()}")

honyk
Posts: 150
Joined: 28 Sep 2010, 11:14

09 Apr 2011, 12:30

Thanks, that ajax settings works (both with bracket or without them)! I wasn't aware it is necessary.

honyk
Posts: 150
Joined: 28 Sep 2010, 11:14

09 Apr 2011, 12:36

Looking into the background, I've found this nice explanation:
http://stackoverflow.com/questions/4900 ... o-new-page
The Primefaces' p:commandLink fires by default an ajax request. It does not return a whole HTTP response, but only a partial HTTP response which has got to be updated in HTML DOM tree by JS.

Ok, I'll keep it in mind.

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

09 Apr 2011, 13:19


Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests