Hi All,
I am looking for a bit of clarification on how the AjaxFormLoop is used
and was hoping that someone else out there may have it working and could
provide a little guidance.
I have searched high and low for some examples but they seem pretty thin
on the ground so far, but I have managed to get most of it working. The
form displays, I can remove items, I can click on the add row link and
onAddRow gets called, the visible page gets updated with a new row, but
none of the values that I specified for the add are present either
visibly or via any of the get / setters in the page class.
Now, I think I may have a misunderstanding as to how the component
works, but feel that my understanding of how it works is the right way :)
Initially, my understanding was that upon clicking the AddRowLink, any
details associated with the add row would be set int eh page class and
then the onAddRow would be called, allowing onAddRow to validate, check,
transform, construct and eventually persisting the newly added record to
the database, and then returning the fully populated object to the page
to be displayed.
After a bit of debugging, I have found that the set methods for the
fields that are being added via the AddRowLink are not called meaning
that you can not construct, populate and persist the newly added record,
which makes me think that the persisting may not be intended to happen
until a form submit has happened.
Below is an extract of what I am trying to do in the page :
<td>
<t:form>
<t:errors/>
<table>
<tr>
<td>Day</td>
<td>Start Hour</td>
<td>Start Minute</td>
<td>Finish Hour</td>
<td>Finish Minute</td>
<td>Action</td>
</tr>
<tr t:type="AjaxFormLoop" source="campaign.calendars"
value="currentCalendar" encoder="encoder">
<td>${currentCalendar.dayOfWeek}</td>
<td>${currentCalendar.startHour}</td>
<td>${currentCalendar.startMinute}</td>
<td>${currentCalendar.finishHour}</td>
<td>${currentCalendar.finishMinute}</td>
<td><t:removerowlink>Remove</t:removerowlink></td>
<t:parameter name="addRow"> <td><t:select t:id="dayOfWeek"
t:value="dayOfWeek" t:model="weekdays" /></td>
<td><input t:type="TextField" t:id="startHour" t:value="startHour"
t:validate="required,min=0,max=23" size="2" /></td> <td><input
t:type="TextField" t:id="startMinute" t:value="startMinute"
t:validate="required,min=0,max=59" size="2" /></td> <td><input
t:type="TextField" t:id="finishHour" t:value="finishHour"
t:validate="required,min=0,max=23" size="2" /></td> <td><input
t:type="TextField" t:id="finishMinute" t:value="finishMinute"
t:validate="required,min=0,max=59" size="2" /></td>
<td><t:addrowlink>Add</t:addrowlink></td>
</t:parameter>
</tr>
</table>
</t:form>
</td>
And what i was trying to do in onAddRow()
public CampaignCalendar onAddRow() {
CampaignCalendar calendar = new CampaignCalendar();
calendar.setCampaign(_campaign);
calendar.setDayOfWeek(dayOfWeek);
calendar.setStartHour(_startHour);
calendar.setStartMinute(_startMinute);
calendar.setFinishHour(_finishHour);
calendar.setFinishMinute(_finishMinute);
calendar =
getBusinessServicesLocater().getCampaignCalendarService().save(calendar);
return calendar;
}
What I would like to see happen in the above is that when the AddRowLink
is selected, the values of dayOfWeek, startHour, startMinute, finishHour
and finishMinute are available to onAddRow so that a new object can be
instantiated and persisted, am I on the right track here? Or do I need
to do that post form submit?
If the persisting is meant to happen post form submit, it doesnt seem to
make sense to me - we have made a request from the client back to the
server to call onAddRow, isnt the idea of ajax to allow incremental
modifications such as this, not just updating the page but actually
performing the back end processing incrementally as well?
Cheers,
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]