aspose file tools*
The moose likes JSF and the fly likes How to call a jsf bean method from a html hyperlink? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to call a jsf bean method from a html hyperlink?" Watch "How to call a jsf bean method from a html hyperlink?" New topic
Author

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

mohammed moin
Greenhorn

Joined: Dec 01, 2007
Posts: 10
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

Joined: Jun 25, 2001
Posts: 15665
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
mohammed moin
Greenhorn

Joined: Dec 01, 2007
Posts: 10
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
 
subject: How to call a jsf bean method from a html hyperlink?
 
Similar Threads
Object as a parameter
Why can't I get object in request scope?
JSF Navigation Issue
Error: Target Unreachable, identifier 'StoreNameBean' resolved to null
Evaluating 2 expressions in JSF using JSTL if tag