• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

UI:repeat UI:include

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a xhtml with a ui:repeat.
In the ui:repeat I have a commandlink with Ajax that points to a certain ID to get rendered.


In this ui:repeat I also have a UI:include with the element that needs to be rendered.

1) I have tried to move my ui:include outside of the ui:repeat to avoid that it's generated multiple times.
If I do this, I get an error saying that the the element the rendered points to doesn't exist.
So I am guessing that when the UI:repeat is built the ui:include is not visible yet because it's outside the ui:repeat

2) When I click on the first item in my ui:repeat that should render the element it works like a charm - the data is updated in the elemnt
However, if I click on any other item in my ui:repeat - it doesn't render the element.

How can that be? I can see that Ajax returns the right values.

I will provide you with code in a minute, I just have to strip it a bit first.
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Peter!

It's best not to think of a JSF View Template (the xhtml file) as something programmable. The "commands" on a View Template should concern themselves only with page layout and not business logic. Not that what you're doing sounds like business logic, but if you're using ui:repeat, chances are that you're thinking about "programming" the View.

I try to avoid ui:repeat for the most part. If I need organized repetitive data, my first choice is to use the h:dataTable or one of its derivatives. However, dataTables are designed for vertical organization of rows, so for things like horizontal repetition, the ui:repeat comes in handy.

I'm afraid your description is too vague to offer more than general guidelines, though. If you could provide a short example, it would help a lot. And if you use the "Code" button to wrap format tags around the XML, it will make it nice and readable.
 
Peter Knudsen
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If anyone else should encounter this problem, here is what I found out:

I moved the include-tag outside of the ui:repeat.

The problem with that was that the <f:ajax> tag couldn't render the component, it pointed to it but it didn't seem visible.
This was caused by a <form> in af <form>. Once I sorted that out, everything fell into place.

The ID's were now ok and the slide-in would render every time.

So remember to check for nested forms!
 
Tim Holloway
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Peter Knudsen wrote:
So remember to check for nested forms!



This is very important. JSF forms are based on HTML forms, and HTML does not permit nested forms.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!