<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.26.0">
</HEAD>
<BODY>
Ok, so perhaps I should explain my dataTable/ui:repeat use case a little bit more, since it seems like some of these options are not going very smoothly for me. I've labeled 3 questions, just to keep this long message slightly more organized.<BR>
<BR>
<B>The Scenario:</B><BR>
-----------------------------------------------------------------------<BR>
<BR>
Everything on your website is RequestScoped -- There are no stateful pages or SessionScoped beans whatsoever. That means that data is loaded every time a user accesses a page via GET, POST, etc... if an ajax event on a page updates some value - it actually needs to be updated via a service call on the back-end.<BR>
<BR>
You have an Object: &quot;Task&quot; -- a Task has an Assignee, a few Dates, and a Status.<BR>
<BR>
In order to keep the look and feel of Tasks consistent on the UI, you've created a &quot;taskBlock.xhtml&quot; composite component to handle the layout. However -- you would like inline editing and updating of the Task data to work via Ajax.<BR>
<BR>
Each taskBlock component instance needs to be able to save, delete its given Task object instance. Hence, you need:<BR>
<BR>
* a delete(Task) action to occur on a commandButton action event (this part is easy thanks to JBoss Seam/EL2)<BR>
* a save(Task) method to be called on a ValueChangeEvent for each editable field <BR>
<BR>
The latter is the hard part, because the task object may have come from a list, it may have been passed in by itself. A workaround would be to have a &quot;Save&quot; button, but that's an extra click for the user, and ugly, etc, lots of reasons why you wouldn't want this. ValueChanceListeners do not accept properties, or allow user-specified ValueChange Methods to be supplied.<BR>
<BR>
<B>Solutions?</B><BR>
-----------------------------------------------------------------------<BR>
<BR>
I tried including a hidden commandLink in the Ajax execute=&quot;&quot; attribute in order to trigger the action after the ValueChangeEvent, but it never fires -- not sure if that's a bug or intended.<BR>
<BR>
<B>**Question 1: </B>Almost every AJAX framework I know of allows you to simply execute a method on the server side, with or without params, and return a result... is this possible with JSF's Ajax framework?<BR>
<BR>
What would be optimal, would be if you could supply, as mentioned in a previous message in this chain, a ValueChangeMethod:<BR>
<BR>
&lt;h:inputText&gt;<BR>
&nbsp;&nbsp;&nbsp; &lt;f:valueChangeMethod method=&quot;saveTask(t)&quot; /&gt;<BR>
&lt;/h:inputText&gt;<BR>
<BR>
or<BR>
<BR>
&nbsp;&nbsp;&nbsp; &lt;f:valueChangeMethod method=&quot;saveTask(event, t)&quot; /&gt;<BR>
<BR>
Which is even more powerful if you consider the new EL, or JBoss EL. If the method contains a &quot;ValueChangeEvent event&quot; in the method signature, it should be injected into the call.<BR>
<BR>
Thus, you would not have to write extra classes, or bind any objects, or retrieve any rows from a DataModel or DataTable.<BR>
<BR>
<B>**Question 2:</B> Without changing the Spec, how would you achieve this and ensure the user interaction is the same? The value needs to be saved via Ajax when they change it on the UI... without clicking a save button. If there is no way to support this type of functionality in the spec currently, then I propose we add it.<BR>
<BR>
<B>**Question 3:</B> Is this really an uncommon use case? Does everyone make a separate view/edit page for lists of items? <BR>
<BR>
The UI JavaScript, CSS, and HTML is not my strong point -- perhaps a component writer would invest more time with JSF's Ajax JavaScript in order to get the behavior right via custom JS, CS, and HTML..?<BR>
<BR>
I'm basically trying to figure out if I'm way off base here, and need a paradigm readjustment. It seems like nobody else is raising issues like this online, so it's possible that JSF doesn't need to change; I'd just like to know what everyone else is eating before I push for a change ;)<BR>
<BR>
--Lincoln<BR>
<BR>
<BR>
On Fri, 2009-08-07 at 14:14 -0700, Alexander Smirnov wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
ui:repeat is a normal JSF component that supports binding but 
&lt;c:forEach&gt; is compilation directive only that has no component 
associated with tag.
The question just recalls me one forgotten problem: h:dataTable and 
ui:repeat is complete different components that doing similar jobs. 
While ui:repeat knows about UIDataTable and works well inside it, 
DataTable itself has no clue what UIRepeat is iteration component, 
therefore rendering a set of tables using ui:repeat is not possible.


On 08/03/2009 12:54 PM, Lincoln Baxter, III wrote:
&gt; So here's one of those, &quot;why is this different than that?&quot; questions:
&gt;
&gt; Unless I'm mistaken, ui:repeat is not a component and therefore cannot
&gt; be bound to a backing bean, but -- would it make sense to support
&gt; something *like* &lt;h:dataTable&gt; in order to support determining the
&gt; selected row on action events and value change events? A component that
&gt; would privide a bindable DataModel / List&lt;Object&gt; row access like
&gt; &lt;h:dataTable&gt;?
&gt;
&gt; *My use case is this:*
&gt;
&gt;     * Managed Bean contains a List of objects
&gt;     * Each object rendered to screen with input field
&gt;     * User submits the input field (with a command link or button, etc)
&gt;     * ManagedBean needs to take action on the appropriate row values
&gt;
&gt;
&gt; I have a list of objects - I need to render them onto the screen (not
&gt; necessarily in an HTML table, maybe a &lt;ul&gt; would be nicer) but I can't
&gt; use &lt;ui:repeat&gt; because each row has a commandLink, and I need to be
&gt; able to determine which row the user clicked on in order to take the
&gt; appropriate action.
&gt;
&gt; EL2 helps with this, but... now what if I have a ValueChangeEvent for an
&gt; input field on each &lt;li&gt; row? Now I can no longer use EL2 to pass the
&gt; row into the ValueChangeListener, and I would have to use something like
&gt; &lt;f:setPropertyActionListener&gt; which is not only getting increasingly
&gt; complicated, but I'd also have to set an attribute /inside/the VCL
&gt; itself, or in a bean VCL knows about - then referencing it - which is
&gt; terribly ugly. Now try to fit all that into a composite component and it
&gt; gets really ugly to try attaching tons of VCLs or ALs or SPALs to values
&gt; inside the component.
&gt;
&gt; Am I attacking this problem in the wrong way? Is this one of those
&gt; things that has an easy solution I'm not seeing? Or is this a genuine gap?
&gt;
&gt; --Lincoln
&gt;
&gt;
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>