Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call a jsf bean method from a html hyperlink?

 
mohammed moin
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

I need solution for this from you.

I have a html hyperlink in a web page, <a href="1.jsf">Home</a>,

The problem is, when i click on the hyperlink, the control should be redirected to a jsf bean method, perform some computations and then again the control should be transferred to another jsp web page.

How to write code for this problem?

Any help will be greatly appreciated.

Thanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17627
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that this is suitable for JSF - it ignores or breaks too many of the JSF framework requirements.

However, there's a fairly simple alternative. Instead of routing your request via a JSF URL, write a small servlet whose doGet method invokes the JSF bean's method of interest and then forwards to the output JSP.

JSF beans aren't only accessible via JSF - it's perfectly valid to use them in any context as long as what you're doing isn't invoking JSF framework services, since there wouldn't be a JSF context when you invoke from a servlet or JSP.

You could simplify even more by making the target JSP invoke the JSF bean method, but that would violate the idea of Separation of Concerns. You'd get a simpler webapp but sacrifice some flexibility.
 
mohammed moin
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

"You could simplify even more by making the target JSP invoke the JSF bean method, but that would violate the idea of Separation of Concerns. You'd get a simpler webapp but sacrifice some flexibility."

Can you provide me code for this solution?

Help will be greatly appreciated?

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic