• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling backing bean from a struts application

 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18100
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic