I want to encapsulate a site-wide bookmarkable URL GET link strategy as a reusable component. I have a number of entity classes (Activity, Actor, Block, ..) that extend Element. Each entity class T has its own <T>Manager as managed bean. In many pages I want to be able to link (via bookmarkable GET URL) to view page for many entities. There is a lot of repetition in the coding for table columns with links:
I want to encapsulate the link part as a reusable component: resources/util/view_link.xhtml:
However for some reason I can't pass the dataTable loop var to the custom composite.This fails:
The error reported claims that "The following attribute(s) are required, but no values have been supplied for them: element. ", but clearly the var 'actor' is not null (I've checked).
It seems one can't pass loop variables to components this way. If so:
Because a dataTable isn't a loop. It's a 2-dimensional display. It would be fully within its rights to run the entire set of rows as parallel operations and that would still be within the JSF2 spec definition.
However, more to the point, you're attempting to pass a Java object through a text channel. Think about that for a second. Java objects are binary constructs. When you render a page, the EL expressions are applied and the controllers use the results to render text. Then when you submit the page, text gets sent back down to the server. So EL that resolves to complex objects doesn't fit.
What you can do is add a property to your model object that renders it as text. Sometimes that can be as simple as:
And reference the "actor.textValue" attribute in your EL.
It depends on what form you want to use.
If the object in question is a database object, you might want to only render the key and let the second stage of the process use that key to retrieve the object. Or, if you prefer something more secure, generate a UUID, stash the object handle in your HttpSession using that UUID as the attribute name, render the object reference as the UUID, then have the backend pluck it back out of the HttpSession.
Customer surveys are for companies who didn't pay proper attention to begin with.
subject: JSF2 how pass dataTable loop var to custom component