Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get rid of passing parameters through Internet?

 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18012
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic