File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes how to make commandButton do nothing if bind no managed bean method? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "how to make commandButton do nothing if bind no managed bean method?" Watch "how to make commandButton do nothing if bind no managed bean method?" New topic
Author

how to make commandButton do nothing if bind no managed bean method?

ym feng
Ranch Hand

Joined: Mar 19, 2009
Posts: 31
managed bean method will be invoked, according to id of commandButton, right? so business logic will be processed exactlly although generated html source code be like "onclick="return false" ".

but, if no managed bean method binded, such as a Cancel button, the whole page will be reloaded, which should not be.

then, how to prevent it, if click Cancel button?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
ym feng wrote:managed bean method will be invoked, according to id of commandButton, right?

That's correct.

so business logic will be processed exactlly although generated html source code be like "onclick="return false" ".

That's not correct. No request would be fired to the server side.

but, if no managed bean method binded, such as a Cancel button, the whole page will be reloaded, which should not be.

then, how to prevent it, if click Cancel button?

Let the onclick return false or use a plain vanilla button, e.g. <input type="button">.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
ym feng
Ranch Hand

Joined: Mar 19, 2009
Posts: 31
Bauke Scholtz wrote:
ym feng wrote:managed bean method will be invoked, according to id of commandButton, right?

That's correct.

so business logic will be processed exactlly although generated html source code be like &quot;onclick=&quot;return false&quot; &quot;.

That's not correct. No request would be fired to the server side.

but, if no managed bean method binded, such as a Cancel button, the whole page will be reloaded, which should not be.

then, how to prevent it, if click Cancel button?

Let the onclick return false or use a plain vanilla button, e.g. <input type="button">.


first i want to thanks for your reply.

i found that if no binded action for a commandButton, the page actually refresh after clicking it with no business logic processed. It's just due to JSF mechanism?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Oh dear, you crossposted the same question at another forum: http://forums.sun.com/thread.jspa?threadID=537622 Please don't do that, this waste of my time and effort is not appreciated. Also see http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
ym feng
Ranch Hand

Joined: Mar 19, 2009
Posts: 31
Bauke Scholtz wrote:Oh dear, you crossposted the same question at another forum: http://forums.sun.com/thread.jspa?threadID=537622 Please don't do that, this waste of my time and effort is not appreciated. Also see http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites


I apologize for what I did!
It will never happen again from now on.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to make commandButton do nothing if bind no managed bean method?
 
Similar Threads
Bean value doubt
JSF: Hitting Enter on an inputText component
Help. commandButton does not invoke Bean's method.
onclick row action in dataTable
Problem with commandButton inside dataTable