• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsf problem with iteration in a page

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,

I am looking to solve what on paper seems an easy problem but I spend a few hours yesterday and I was not able to come to a conclusion.

I am trying to iterate over a list in a jsf, the catch is, whatever tag I use I can't have it spitting out any html at all.

I have tried a combination of jstl and jsf, but they don't mix, it does not let me re-use what I set in the var in the jstl loop inside my jsf tag.
Also, I tried jsp scriptlet and jsf, but f:param does not allow me to enter any expression like this <%=
In production, we don't have facelets installed so it will be hard for me to push to get it installed.

Do you have any idea or can you send me to the right direction...

thanks
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, John!

JSF is a very pure implementation of the MVC design paradigm. In MVC, logic belongs in the Controller, not in the View. In other words, not in the web page, in scriptlets, in JSTL (which, as you're discovered, don't work well in JSF), not in JavaScript, or whatever.

JSF is also abstract. If you look at the docs for the dataTable control, for example, I don't think you'll find the words "loop" or "iterate" anywhere in there. A dataTable is a 2-dimensional rendering of data, and the mechanism used to enumerate that data isn't important.

I'm unclear on what the actual abstract goal you have in mind, however. We recently had someone else with a similar question, so you may want to search around this forum and see if that thread helps.
 
John Cuzzola
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I was not clear, I understand how mvcs work.
I have a list
I want to "loop" and create <divs> with inside a commandlink and a image. Inside the commandlink I have to pass a couple of f:param (which are iterated in the list).
We used to use datatables but it generates html tables, while I don't want any html beside the divs I create in the loop.

I hope it makes clear.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the whole anti-table jihad thing died out years ago. JSF is an abstract framework and I no more care what sort of HTML comes out of it than I do which assembly-language instructions Java uses to execute code. As long as the display comes out proper, only PHBs with nothing more constructive to do (like, say, maybe ensuring that apps are truly secure) and nerds have any reason to care.

Sorry, you touched a nerve. Besides, if ideology is going to drive things, my own policy is to not embed HTML in JSF Views at all. It mucks up the JSF renderer, which is supposed to be operating independent of the display medium selected. So I use JSF panelGrids and let the renderer worry about whether a 1x1 panelGrid should come out as a table, div, or something completely other.

Nevertheless. If you absolutely MUST do divs, use the ui:repeat Facelets tag. Assuming there's not an edict about that one too.
 
John Cuzzola
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I know what you mean about table vs divs. I am a software developer, so I could not care less which one I use, but I work for a big company and that was a requirements from the designer so my hands are tight.
I found a solution with facelets, but funny thing, I cannot use it either. It is a major website and to add a library it is a pain to get approval.
that's the reason why I tried scriptlet and it did not work either. I don't have many options.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic