• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
ym feng
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">.
 
ym feng
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!