wood burning stoves 2.0*
The moose likes JSF and the fly likes How to get rid of passing parameters through Internet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to get rid of passing parameters through Internet?" Watch "How to get rid of passing parameters through Internet?" New topic
Author

How to get rid of passing parameters through Internet?

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

I have this command link that should assign forumBacking.forumName property with needed forum's name

When I click this link I have correct forum name assigned to forumBacking.forumName . But I want to move to next page clicking this link without passing any parameters. I have mapping in pretty-config

This mapping is bad because it matches parent_mapping(forums) + "/". It means that user types in browser bar what matches and receives nothing because forumBacking.forumName is not assigned with <f:setPropertyActionListener>

I dont' want to pass forum.name as a parameter because Tim Holloway says it is bad idea!


True person is moral, false is right!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

I assert that passing parameters is a bad idea because you are, in effect putting logic in a View, and a View shouldn't be running application code, it should be displaying things.

However, there's more than one way to "pass a parameter", especially when you're running PrettyFaces, where you can code something like this:

<h:outputLink styleClass="forumNameLink" value="/forums/id/#{myBean.forumId}">#{myBean.forumName}</h:outputLink>


Stuff like this allows you to make bookmarkable URLs, in addition to "passing a parameter".

This isn't a solution for every problem, since it does expose data on the client side; though in this case, we want to expose that data. For a more secure link (and/or one where the "parameter" data is larger), you should inject a common Managed Bean accessible on the target View into the backing bean that contains a commandLink action method, let the action method post the data to that injected bean via a property setter, then return the "pretty:forumInnerLink" navigation directive as the action method's return value. And get rid of the propertyActionListener.




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: How to get rid of passing parameters through Internet?
 
Similar Threads
How to style h:dataTable?
submit form only by pressing enter
redirect & parameter passing
Changing Views with navigation handler in java and sending params to the changed view
Resolve f:param value at link construction time