*
The moose likes JSF and the fly likes Questions regard webpage logic construction & GET behaviour. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Questions regard webpage logic construction & GET behaviour." Watch "Questions regard webpage logic construction & GET behaviour." New topic
Author

Questions regard webpage logic construction & GET behaviour.

Hugo Alberto Bedolla
Greenhorn

Joined: Nov 09, 2010
Posts: 17
Hi everybody: I'm newbie with using JSF. I've two questions basically, by now:

First: How do I address logic with JSF at the web page? It means, making conditional decisions while rendering the output (if 'a satisties condition' render some, else render another one; i.e. Struts logic tags).

Second: How do I address a GET behavior?... as I understand, JSF does intensive using of POST behaviour, but I need basically to assemble my view depending on what variables are sent by the user (the classic '?secName=section1&var1=val1&var2=val2'), by putting there some components and no others depending on what the values of variables are, all in the same view (I looked book examples where authors does five+more pages for to present the same kind of data, what I consider simply annoying, as it converts into a static view what inherently needs to be dynamic) .

I would love to have two concrete examples about this. Thanks in advance .
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
A conditional decision to render a component or not is done commonly with the "rendered" attribute.
If the expression for rendered evaluates to true, the component gets rendered. If not, it doesn't.
You can do it on a container object like a panelGroup to include/exclude sections of the page.

With regards to the second, I would create a bean to store those parameters in. The binding would go to that bean, and then you could render your view based on those bean properties.
However passing parameters around manually is not something that JSF does as far as I can tell. Paradigms that work well in other frameworks may not necessarily apply to JSF - and trying to force JSF to work that way is often detrimental.
In other words, don't try and force a square peg into a round hole.
Hugo Alberto Bedolla
Greenhorn

Joined: Nov 09, 2010
Posts: 17
Stefan Evans wrote:A conditional decision to render a component or not is done commonly with the "rendered" attribute.
If the expression for rendered evaluates to true, the component gets rendered. If not, it doesn't.
You can do it on a container object like a panelGroup to include/exclude sections of the page.

With regards to the second, I would create a bean to store those parameters in. The binding would go to that bean, and then you could render your view based on those bean properties.
However passing parameters around manually is not something that JSF does as far as I can tell. Paradigms that work well in other frameworks may not necessarily apply to JSF - and trying to force JSF to work that way is often detrimental.
In other words, don't try and force a square peg into a round hole.


Hi Stefan... regarding the first question I think your answer solves the issue for me :). Regard the second question I was a little confused yet but looking around I found I can attach any <f:param> tags to any <h:outputLink> tag which seems to be straightforward for to obtain that kind of behaviour, it by catching the parameters with a backing bean as you rightly wrote, while spreading to all any other components calls to boolean javabean methods that evaluates the rendering and what info to put into.

I found your answer very useful as it oriented my vision about the JSF approach. Thanks so much again for your feedback.



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

Hi Hugo. Believe Stefan when he says that JSF does things differently. JSF usually passes stuff around in backing beans, not in parameters. For one thing, JSF is very big into postback operations, and - as many have discovered to their sorrow and frustration - the URL isn't necessarily a direct reflection of the View resource being rendered


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: Questions regard webpage logic construction & GET behaviour.