• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions regard webpage logic construction & GET behaviour.

 
Hugo Alberto Bedolla
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1743
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic