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 Calling backing bean from a struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Calling backing bean from a struts application" Watch "Calling backing bean from a struts application" New topic
Author

Calling backing bean from a struts application

Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Hi all- There is one entry point to my application(JSF) from other application(Struts). My URL will be called with the information in hidden fields. How to map the URL to the JSF controller? Or the URL should point to a jsp and on loading the jsp Page we have to call the Controller. Please let me know how to do this.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Shasi Mitra wrote:Hi all- There is one entry point to my application(JSF) from other application(Struts). My URL will be called with the information in hidden fields. How to map the URL to the JSF controller? Or the URL should point to a jsp and on loading the jsp Page we have to call the Controller. Please let me know how to do this.


To map a URL to the JSF controller, you do just like any other URL. You define a URL-to-servlet mapping in web.xml and indicate that the target servlet is the JSF servlet. A single webapp can contain both Struts and JSF, you don't actually need separate webapps.

The more challenging part is getting your parameters. JSF normally works with its own internal POST protocol. The exception is when you first enter a page.

Although a JSF backing bean CAN root its way through the internal structures and locate the original HTTPServletRequest, then pull the parameters from it, there's another, cleaner way too. Check out the PrettyFaces project. It's a small jar, a servlet filter (configured in web.xml) and a user-defined URL mapping/config file that can be used to pass traditional URL requests to JSF. It's actually much tidier than the more common way of picking parameters out by brute force.

Just as a side note, I don't recommend using hidden fields unless you have to. Sometimes there's no choice, but I prefer to keep secret data server-side, since anything sent out to the client and back can be hacked.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling backing bean from a struts application