File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

How to get rid of passing parameters through Internet?

Volodymyr Lysenko
Ranch Hand

Joined: Mar 29, 2012
Posts: 511

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 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: 17417

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to get rid of passing parameters through Internet?
It's not a secret anymore!