You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christopher Corde <cc...@yahoo.com> on 2004/01/20 23:38:13 UTC
Dynamically naming components inside a Foreach
Hey,
I have what I believe is a simple question, I just
cant find the answer anywhere. I have a foreach loop
in my HTML, which can contain any number of TextField
components inside a table. I want to name the
textfield components based on some property of the
current Foreach row, but cant seem to figure it out.
Here is my HTML:
<form jwcid="@Form"
listener="ognl:listeners.formSubmit">
<table border=1>
<tr jwcid="@Foreach" source="ognl:editDetailsList"
value="ognl:editDetailsInfo" element="tr">
<td><span jwcid="@Insert"
value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
<td><span jwcid="@TextField"
value="ognl:editDetailsInfo.fieldValue"
size="15"/></td>
</tr>
<tr><td> </td><td><input type="submit"
value="Submit"/></td>
</tr>
</table>
</form>
What I essentially want to do is put
"ognl:editDetailsInfo.fieldDisplayName@TextField", so
I can grab the correct values at form submittal. Any
ideas how to do this, or if Im doing it wrong, the
correct way to get it done?
Thanks,
Chris Corde
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Dynamically naming components inside a Foreach
Posted by Christopher Corde <cc...@yahoo.com>.
That worked perfectly! Thanks for the help.
Chris
--- Jamie Orchard-Hays <ja...@dang.com> wrote:
> Are you using a ListEditMap? It doesn't look like
> it. Here's an example:
>
> Java:
> public abstract class PersonalSchedule extends
> MyBasePage implements
> PageRenderListener{
> ...
> //the ListEditMap
> public abstract void setListEditMap(ListEditMap
> map);
> public abstract ListEditMap getListEditMap();
> .....
> //listener
> public void updateSlot(IRequestCycle cycle){
> LOG.debug("updateSlot()");
> ListEditMap map = getListEditMap();
>
> setSlot((PersonalScheduleSlot)map.getValue());
> }
> ...
> //form listener
> public void updateSchedule(IRequestCycle cycle){
> LOG.debug("updateSchedule()");
> ListEditMap map = getListEditMap();
> List updatedSlots = map.getValues();
> PersonalScheduleSlot [] slots =
> (PersonalScheduleSlot[])
> updatedSlots.toArray(new
> PersonalScheduleSlot[updatedSlots.size()]);
> for (int i = 0; i < slots.length; i++) {
> PersonalScheduleSlot slot = slots[i];
> LOG.debug("slot update: " +
> slot.getBeginDate() + " to " +
> slot.getEndDate());
> }
> try {
>
>
getStudentPersonalScheduleMethods().updatePersonalSchedule(slots);
> } catch (SystemException e) {
> throw new
> ApplicationRuntimeException(e);
> }
> }
> }
>
> .page file:
> <property-specification name="listEditMap"
> type="org.apache.tapestry.form.ListEditMap" />
> <property-specification name="personalSchedule"
>
type="edu.darden.career.data.value.PersonalScheduleSlot[]"
> />
> <property-specification name="slot"
>
type="edu.darden.career.data.value.PersonalScheduleSlot"
> />
> ...
> <component id="scheduleForm" type="Form">
> <binding name="listener"
> expression="listeners.updateSchedule" />
> </component>
>
> <component id="schedule" type="ListEdit">
> <binding name="source"
> expression="listEditMap.keys"/>
> <binding name="value"
> expression="listEditMap.key"/>
> <binding name="listener"
> expression="listeners.updateSlot"/>
> <binding name="index"
> expression="scheduleIndex"/>
> <static-binding name="element" value="tr"/>
> </component>
>
>
> ----- Original Message -----
> From: "Christopher Corde" <cc...@yahoo.com>
> To: "Tapestry users"
> <ta...@jakarta.apache.org>
> Sent: Wednesday, January 21, 2004 10:16 AM
> Subject: Re: Dynamically naming components inside a
> Foreach
>
>
> > Any examples of how to actually use this ListEdit
> > component? I can substitue my Foreach with a
> ListEdit,
> > and I attached a listener that grabs the current
> value
> > binding and asks for its updated value, but the
> value
> > coming back is the original form parameter. Any
> ideas
> > what I might be doing wrong?
> >
> > <form jwcid="@Form"
> > listener="ognl:listeners.formSubmit">
> > <table border=1>
> > <tr jwcid="formEditList@ListEdit"
> > source="ognl:editDetailsList"
> > value="ognl:editDetailsInfo" element="tr"
> > listener="ognl:listeners.listEditUpdated">
> > <td><span jwcid="@Insert"
> >
>
value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
> > <td><span jwcid="@TextField"
> > value="ognl:editDetailsInfo.fieldValue"
> > size="15"/></td>
> > </tr>
> > <tr><td> </td><td><input type="submit"
> > value="Submit"/></td>
> > </tr>
> > </table>
> > </form>
> >
> >
> > .java:
> >
> > public void formSubmit(IRequestCycle requestCycle)
> {
> > tapestryLogger.debug("Form submitted.");
> > }
> >
> > public void listEditUpdated(IRequestCycle
> > requestCycle) {
> > tapestryLogger.debug("List Edit Updated.");
> > ListEdit listEdit = (ListEdit)
> > this.getComponent("formEditList");
> > EditDetailsInfo obj = (EditDetailsInfo)
> > listEdit.getValueBinding().getObject();
> > tapestryLogger.debug(obj.getFieldName() + ": " +
> > obj.getFieldValue());
> > }
> >
> > the listEditUpdated method just returns the
> original
> > values after the form is submitted.
> >
> > Thanks,
> > Chris
> >
> > --- Jamie Orchard-Hays <ja...@dang.com> wrote:
> > > Have a look at the ListEdit component. I think
> that
> > > might help you out:
> > >
> > >
> >
>
http://jakarta.apache.org/tapestry/doc/ComponentReference/ListEdit.html
> > >
> > > Jamie
> > >
> > >
> > > ----- Original Message -----
> > > From: "Christopher Corde" <cc...@yahoo.com>
> > > To: "Tapestry"
> <ta...@jakarta.apache.org>
> > > Sent: Tuesday, January 20, 2004 5:38 PM
> > > Subject: Dynamically naming components inside a
> > > Foreach
> > >
> > >
> > > > Hey,
> > > >
> > > > I have what I believe is a simple question,
> I
> > > just
> > > > cant find the answer anywhere. I have a
> foreach
> > > loop
> > > > in my HTML, which can contain any number of
> > > TextField
> > > > components inside a table. I want to name the
> > > > textfield components based on some property of
> the
> > > > current Foreach row, but cant seem to figure
> it
> > > out.
> > > > Here is my HTML:
> > > >
> > > > <form jwcid="@Form"
> > > > listener="ognl:listeners.formSubmit">
> > > > <table border=1>
> > > > <tr jwcid="@Foreach"
> source="ognl:editDetailsList"
> > > > value="ognl:editDetailsInfo" element="tr">
> > > > <td><span jwcid="@Insert"
> > > >
> > >
> >
>
value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
> > > > <td><span jwcid="@TextField"
> > > > value="ognl:editDetailsInfo.fieldValue"
> > > > size="15"/></td>
> > > > </tr>
> > > > <tr><td> </td><td><input
> type="submit"
> > > > value="Submit"/></td>
> > > > </tr>
> > > > </table>
> > > > </form>
> > > >
>
=== message truncated ===
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Dynamically naming components inside a Foreach
Posted by Jamie Orchard-Hays <ja...@dang.com>.
Are you using a ListEditMap? It doesn't look like it. Here's an example:
Java:
public abstract class PersonalSchedule extends MyBasePage implements
PageRenderListener{
...
//the ListEditMap
public abstract void setListEditMap(ListEditMap map);
public abstract ListEditMap getListEditMap();
.....
//listener
public void updateSlot(IRequestCycle cycle){
LOG.debug("updateSlot()");
ListEditMap map = getListEditMap();
setSlot((PersonalScheduleSlot)map.getValue());
}
...
//form listener
public void updateSchedule(IRequestCycle cycle){
LOG.debug("updateSchedule()");
ListEditMap map = getListEditMap();
List updatedSlots = map.getValues();
PersonalScheduleSlot [] slots = (PersonalScheduleSlot[])
updatedSlots.toArray(new PersonalScheduleSlot[updatedSlots.size()]);
for (int i = 0; i < slots.length; i++) {
PersonalScheduleSlot slot = slots[i];
LOG.debug("slot update: " + slot.getBeginDate() + " to " +
slot.getEndDate());
}
try {
getStudentPersonalScheduleMethods().updatePersonalSchedule(slots);
} catch (SystemException e) {
throw new ApplicationRuntimeException(e);
}
}
}
.page file:
<property-specification name="listEditMap"
type="org.apache.tapestry.form.ListEditMap" />
<property-specification name="personalSchedule"
type="edu.darden.career.data.value.PersonalScheduleSlot[]" />
<property-specification name="slot"
type="edu.darden.career.data.value.PersonalScheduleSlot" />
...
<component id="scheduleForm" type="Form">
<binding name="listener" expression="listeners.updateSchedule" />
</component>
<component id="schedule" type="ListEdit">
<binding name="source" expression="listEditMap.keys"/>
<binding name="value" expression="listEditMap.key"/>
<binding name="listener" expression="listeners.updateSlot"/>
<binding name="index" expression="scheduleIndex"/>
<static-binding name="element" value="tr"/>
</component>
----- Original Message -----
From: "Christopher Corde" <cc...@yahoo.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, January 21, 2004 10:16 AM
Subject: Re: Dynamically naming components inside a Foreach
> Any examples of how to actually use this ListEdit
> component? I can substitue my Foreach with a ListEdit,
> and I attached a listener that grabs the current value
> binding and asks for its updated value, but the value
> coming back is the original form parameter. Any ideas
> what I might be doing wrong?
>
> <form jwcid="@Form"
> listener="ognl:listeners.formSubmit">
> <table border=1>
> <tr jwcid="formEditList@ListEdit"
> source="ognl:editDetailsList"
> value="ognl:editDetailsInfo" element="tr"
> listener="ognl:listeners.listEditUpdated">
> <td><span jwcid="@Insert"
> value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
> <td><span jwcid="@TextField"
> value="ognl:editDetailsInfo.fieldValue"
> size="15"/></td>
> </tr>
> <tr><td> </td><td><input type="submit"
> value="Submit"/></td>
> </tr>
> </table>
> </form>
>
>
> .java:
>
> public void formSubmit(IRequestCycle requestCycle) {
> tapestryLogger.debug("Form submitted.");
> }
>
> public void listEditUpdated(IRequestCycle
> requestCycle) {
> tapestryLogger.debug("List Edit Updated.");
> ListEdit listEdit = (ListEdit)
> this.getComponent("formEditList");
> EditDetailsInfo obj = (EditDetailsInfo)
> listEdit.getValueBinding().getObject();
> tapestryLogger.debug(obj.getFieldName() + ": " +
> obj.getFieldValue());
> }
>
> the listEditUpdated method just returns the original
> values after the form is submitted.
>
> Thanks,
> Chris
>
> --- Jamie Orchard-Hays <ja...@dang.com> wrote:
> > Have a look at the ListEdit component. I think that
> > might help you out:
> >
> >
> http://jakarta.apache.org/tapestry/doc/ComponentReference/ListEdit.html
> >
> > Jamie
> >
> >
> > ----- Original Message -----
> > From: "Christopher Corde" <cc...@yahoo.com>
> > To: "Tapestry" <ta...@jakarta.apache.org>
> > Sent: Tuesday, January 20, 2004 5:38 PM
> > Subject: Dynamically naming components inside a
> > Foreach
> >
> >
> > > Hey,
> > >
> > > I have what I believe is a simple question, I
> > just
> > > cant find the answer anywhere. I have a foreach
> > loop
> > > in my HTML, which can contain any number of
> > TextField
> > > components inside a table. I want to name the
> > > textfield components based on some property of the
> > > current Foreach row, but cant seem to figure it
> > out.
> > > Here is my HTML:
> > >
> > > <form jwcid="@Form"
> > > listener="ognl:listeners.formSubmit">
> > > <table border=1>
> > > <tr jwcid="@Foreach" source="ognl:editDetailsList"
> > > value="ognl:editDetailsInfo" element="tr">
> > > <td><span jwcid="@Insert"
> > >
> >
> value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
> > > <td><span jwcid="@TextField"
> > > value="ognl:editDetailsInfo.fieldValue"
> > > size="15"/></td>
> > > </tr>
> > > <tr><td> </td><td><input type="submit"
> > > value="Submit"/></td>
> > > </tr>
> > > </table>
> > > </form>
> > >
> > > What I essentially want to do is put
> > > "ognl:editDetailsInfo.fieldDisplayName@TextField",
> > so
> > > I can grab the correct values at form submittal.
> > Any
> > > ideas how to do this, or if Im doing it wrong, the
> > > correct way to get it done?
> > >
> > > Thanks,
> > > Chris Corde
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Hotjobs: Enter the "Signing Bonus"
> > Sweepstakes
> > > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > tapestry-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Dynamically naming components inside a Foreach
Posted by Christopher Corde <cc...@yahoo.com>.
Any examples of how to actually use this ListEdit
component? I can substitue my Foreach with a ListEdit,
and I attached a listener that grabs the current value
binding and asks for its updated value, but the value
coming back is the original form parameter. Any ideas
what I might be doing wrong?
<form jwcid="@Form"
listener="ognl:listeners.formSubmit">
<table border=1>
<tr jwcid="formEditList@ListEdit"
source="ognl:editDetailsList"
value="ognl:editDetailsInfo" element="tr"
listener="ognl:listeners.listEditUpdated">
<td><span jwcid="@Insert"
value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
<td><span jwcid="@TextField"
value="ognl:editDetailsInfo.fieldValue"
size="15"/></td>
</tr>
<tr><td> </td><td><input type="submit"
value="Submit"/></td>
</tr>
</table>
</form>
.java:
public void formSubmit(IRequestCycle requestCycle) {
tapestryLogger.debug("Form submitted.");
}
public void listEditUpdated(IRequestCycle
requestCycle) {
tapestryLogger.debug("List Edit Updated.");
ListEdit listEdit = (ListEdit)
this.getComponent("formEditList");
EditDetailsInfo obj = (EditDetailsInfo)
listEdit.getValueBinding().getObject();
tapestryLogger.debug(obj.getFieldName() + ": " +
obj.getFieldValue());
}
the listEditUpdated method just returns the original
values after the form is submitted.
Thanks,
Chris
--- Jamie Orchard-Hays <ja...@dang.com> wrote:
> Have a look at the ListEdit component. I think that
> might help you out:
>
>
http://jakarta.apache.org/tapestry/doc/ComponentReference/ListEdit.html
>
> Jamie
>
>
> ----- Original Message -----
> From: "Christopher Corde" <cc...@yahoo.com>
> To: "Tapestry" <ta...@jakarta.apache.org>
> Sent: Tuesday, January 20, 2004 5:38 PM
> Subject: Dynamically naming components inside a
> Foreach
>
>
> > Hey,
> >
> > I have what I believe is a simple question, I
> just
> > cant find the answer anywhere. I have a foreach
> loop
> > in my HTML, which can contain any number of
> TextField
> > components inside a table. I want to name the
> > textfield components based on some property of the
> > current Foreach row, but cant seem to figure it
> out.
> > Here is my HTML:
> >
> > <form jwcid="@Form"
> > listener="ognl:listeners.formSubmit">
> > <table border=1>
> > <tr jwcid="@Foreach" source="ognl:editDetailsList"
> > value="ognl:editDetailsInfo" element="tr">
> > <td><span jwcid="@Insert"
> >
>
value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
> > <td><span jwcid="@TextField"
> > value="ognl:editDetailsInfo.fieldValue"
> > size="15"/></td>
> > </tr>
> > <tr><td> </td><td><input type="submit"
> > value="Submit"/></td>
> > </tr>
> > </table>
> > </form>
> >
> > What I essentially want to do is put
> > "ognl:editDetailsInfo.fieldDisplayName@TextField",
> so
> > I can grab the correct values at form submittal.
> Any
> > ideas how to do this, or if Im doing it wrong, the
> > correct way to get it done?
> >
> > Thanks,
> > Chris Corde
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus"
> Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> >
> >
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Dynamically naming components inside a Foreach
Posted by Jamie Orchard-Hays <ja...@dang.com>.
Have a look at the ListEdit component. I think that might help you out:
http://jakarta.apache.org/tapestry/doc/ComponentReference/ListEdit.html
Jamie
----- Original Message -----
From: "Christopher Corde" <cc...@yahoo.com>
To: "Tapestry" <ta...@jakarta.apache.org>
Sent: Tuesday, January 20, 2004 5:38 PM
Subject: Dynamically naming components inside a Foreach
> Hey,
>
> I have what I believe is a simple question, I just
> cant find the answer anywhere. I have a foreach loop
> in my HTML, which can contain any number of TextField
> components inside a table. I want to name the
> textfield components based on some property of the
> current Foreach row, but cant seem to figure it out.
> Here is my HTML:
>
> <form jwcid="@Form"
> listener="ognl:listeners.formSubmit">
> <table border=1>
> <tr jwcid="@Foreach" source="ognl:editDetailsList"
> value="ognl:editDetailsInfo" element="tr">
> <td><span jwcid="@Insert"
> value="ognl:editDetailsInfo.fieldDisplayName">Name</span></td>
> <td><span jwcid="@TextField"
> value="ognl:editDetailsInfo.fieldValue"
> size="15"/></td>
> </tr>
> <tr><td> </td><td><input type="submit"
> value="Submit"/></td>
> </tr>
> </table>
> </form>
>
> What I essentially want to do is put
> "ognl:editDetailsInfo.fieldDisplayName@TextField", so
> I can grab the correct values at form submittal. Any
> ideas how to do this, or if Im doing it wrong, the
> correct way to get it done?
>
> Thanks,
> Chris Corde
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org