You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bill Holloway <bi...@peoplepad.com> on 2008/04/17 00:42:51 UTC

T5: BeanForm, processSubmission, AppPropertyEditBlock help

I've got a custom data type called FlexDate, and I've made a simple
<t:flexdateeditor> component for it which (for now) just holds a date
field.  It will get more complex later.  I put this editor into my
AppPropertyEditBlocks.tml.  Code is below.  Then I have a data object with
an instance var of FlexDate type.  I pump this into a beanformeditor.  The
problem is that the elementName arg of processSubmission (in
FlexDateEditor.java) never seems to be in my _request.getParameterNames() so
I can extract the date!  Help?

FlexDateEditor.tml:

<div class="flexDateEditor" xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">

    <t:dateField value="date1" />

</div>

Date1 is defined in FlexDateEditor.java and evaluated to new Date() during
beginRender().

AppPropertyEditBlocks.tml (snippet):

<t:block t:id="flexDate">

        <t:label for="flexDateEditor" />
        <t:flexDateEditor t:id="flexDateEditor" />

</t:block>

The elementName arg of processSubmission in FlexDateEditor.java is always
the name of the instance variable in my data object that goes into
beanformeditor.  Grr.  How can I get the fields of the datefield to be named
that way so I can extract the value?

-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Bill Holloway <bi...@peoplepad.com>.
Almost, processSubmission creates a flexdate from the date and sticks that
into the parameter "flexDate" of FlexDateEditor."  My bean has FlexDate
properties, 4 of them.  That causes the FlexDateEditor to be shown via the
AppPropertyEditBlock.  The datefield gets date1 as a property, which comes
from the flexDate parameter (See first code listing below).  Then in
FlexDateEditor's processSubmission method, date1 is used to construct a new
FlexDate for the FlexDate property of the bean.  You're right, Howard, that
it's the datefield negotiating the controlName.  That's where the hangup
is.  Peter's approach gets the base name right, but its appended with "_0",
"_1", etc.

>From FlexDateEditor:

void beginRender ()
    {
        _flexDate = _flexDate == null ? new FlexDate(
DateSpecificityEnum.EXACT, DatePrecisionEnum.DAY, new Date(), null )
:_flexDate;

        _date1 = new Date();
    }

Here's code from AppPropertyEditBlocks.java

@Component (parameters=
            { "flexDate=context.propertyValue", "label=prop:context.label",
"validate=prop:flexDateValidator",
              "clientId=prop:context.propertyId"})
    private FlexDateEditor _flexDateEditor;

Here's processSubmission of FlexDateEditor:

protected void processSubmission (String elementName)
    {
        String date1Str = _request.getParameter( elementName );

        Date date1 = null;
        try
        {
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            date1 = df.parse(date1Str);
        }
        catch (ParseException e)
        {
            throw new RuntimeException (e);
        }
        _flexDate = new FlexDate( DateSpecificityEnum.EXACT,
DatePrecisionEnum.DAY, date1, null );
    }

On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> Hard to tell without checking the code, but:  looks like the
> FlexDataEditor delegates all its behavior to the built-in DateField
> component, right?
>
> So the DateField is the component that (at render) negotiates an
> control name (i.e., FormSupport.allocateControlName() ), and then
> pushes the parsed and validated date back up.  You should see this in
> the HTML and form submission, a component whose client element has a
> name like "datefield" (or "datefield_0", etc.).
>
> Presumable the DateField is tied to a property of the FlexDateEditor,
> and that property is tied eventually up to your bean.
>
> On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> > I've got a custom data type called FlexDate, and I've made a simple
> >  <t:flexdateeditor> component for it which (for now) just holds a date
> >  field.  It will get more complex later.  I put this editor into my
> >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data object
> with
> >  an instance var of FlexDate type.  I pump this into a beanformeditor.
>  The
> >  problem is that the elementName arg of processSubmission (in
> >  FlexDateEditor.java) never seems to be in my
> _request.getParameterNames() so
> >  I can extract the date!  Help?
> >
> >  FlexDateEditor.tml:
> >
> >  <div class="flexDateEditor" xmlns:t="
> >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> >
> >     <t:dateField value="date1" />
> >
> >  </div>
> >
> >  Date1 is defined in FlexDateEditor.java and evaluated to new Date()
> during
> >  beginRender().
> >
> >  AppPropertyEditBlocks.tml (snippet):
> >
> >  <t:block t:id="flexDate">
> >
> >         <t:label for="flexDateEditor" />
> >         <t:flexDateEditor t:id="flexDateEditor" />
> >
> >  </t:block>
> >
> >  The elementName arg of processSubmission in FlexDateEditor.java is
> always
> >  the name of the instance variable in my data object that goes into
> >  beanformeditor.  Grr.  How can I get the fields of the datefield to be
> named
> >  that way so I can extract the value?
> >
> >  --
> >  Bill @ PeoplePad
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Bill Holloway <bi...@peoplepad.com>.
Thanks, Thiago, yes that is there.  I have "theflexDateEditor_0" in the
input.  I'm wondering what technique I can use to have that integer
extension folded into the elementName variable passed into
processSubmission.

Bill

On Thu, Apr 17, 2008 at 12:24 PM, Thiago HP <th...@gmail.com> wrote:

> On 4/17/08, Bill Holloway <bi...@peoplepad.com> wrote:
> > Ok, below are the flexdateeditor template and class.  Below that is the
> use
> >  of FlexDateEditor in TestPage.tml.  What is below works just fine --
> however
> >  note the appending of a "_0" to the element name in processSubmission.
>
> Tapestry appends a "_n", being n an integer value, to a component id
> when the same id was already used in another component. This happens,
> for example, when you have ActionLink generated inside a Loop or Grid.
> Therefore, I suggest you to take a look at your template *and* in the
> generated HTML file to see if there's any HTML input tag with an
> "theDateEditor" id.
>
> --
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Thiago HP <th...@gmail.com>.
On 4/17/08, Bill Holloway <bi...@peoplepad.com> wrote:
> Ok, below are the flexdateeditor template and class.  Below that is the use
>  of FlexDateEditor in TestPage.tml.  What is below works just fine -- however
>  note the appending of a "_0" to the element name in processSubmission.

Tapestry appends a "_n", being n an integer value, to a component id
when the same id was already used in another component. This happens,
for example, when you have ActionLink generated inside a Loop or Grid.
Therefore, I suggest you to take a look at your template *and* in the
generated HTML file to see if there's any HTML input tag with an
"theDateEditor" id.

-- 
Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Bill Holloway <bi...@peoplepad.com>.
Ok, below are the flexdateeditor template and class.  Below that is the use
of FlexDateEditor in TestPage.tml.  What is below works just fine -- however
note the appending of a "_0" to the element name in processSubmission.
Also, in processSubmission, the element name is "theFlexDateEditor", which
is value of the clientId field given to the flexdateeditor in testpage.tml.
The HTML output of testpage shows (initially) the date field with today's
date as expected.

FlexDateEditor.tml
-------------------------------
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <t:datefield clientId="prop:clientId" name="prop:controlName"
value="date" />
</t:container>

FlexDateEditor.java
--------------------------------
public class FlexDateEditor extends AbstractField
{
    @Parameter
    @Property (write = false)
    private FlexDate _flexDate;

    @Inject private Request _request;
    @Property private Date _date;

    void setupRender () {
        _date = new Date();
    }

    protected void processSubmission (String elementName) {
        String dateStr = _request.getParameter( elementName + "_0" );
        Date date = null;
        try {
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            date = df.parse(dateStr);
        }
        catch (ParseException e) {
            throw new RuntimeException (e);
        }
         _flexDate = new FlexDate( DateSpecificityEnum.EXACT,
DatePrecisionEnum.DAY,
                            date, null ); // Really I should use a
translator
    }
}

TestPage.tml
---------------------
<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <t:form t:id="myForm">
        <t:flexDateEditor clientId="theFlexDateEditor" flexDate="myFlexDate"
/>
        <br />
        <input type="submit" />
    </t:form>
</t:layout>

On Wed, Apr 16, 2008 at 10:44 PM, Howard Lewis Ship <hl...@gmail.com>
wrote:

> Do you still have a DateField inside your FlexDateField?  Could you
> show the full template and the HTML output?  I think we're not quite
> hooking up here.
>
> On Wed, Apr 16, 2008 at 7:16 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> > If I add "_0" to elementName, I'm fine.  But that's fairly brittle :)
> >
> >
> >
> >  On Wed, Apr 16, 2008 at 8:47 PM, Howard Lewis Ship <hl...@gmail.com>
> wrote:
> >
> >  > Well, binding the clientId parameter of DateField can influence what
> >  > the control name will be (though it will be uniqued).
> >  >
> >  > I still don't understand exactly what you are going to pull out of
> the
> >  > request inside the FlexDateEditor's processSubmission().
> >  >
> >  > The DateField is almost undoubtedly scheduled as the next component
> to
> >  > process the submission (its basically render order, and the
> >  > FlexDateField will render before the DateField because the DateField
> >  > is embedded inside the FlexDateField).
> >  >
> >  > The DateField will update its value parameter, which is bound to the,
> >  > well something we haven't seen.
> >  >
> >  > Perhaps what you need is a callback for *after* the embedded
> DateField
> >  > has done its part, and shoved a value into some property of the
> >  > FlexDateField?
> >  >
> >  >
> >  > On Wed, Apr 16, 2008 at 6:14 PM, Bill Holloway <bi...@peoplepad.com>
> wrote:
> >  > > I guess one way to look at it is that in
> AppPropertyEditBlocks.java, I
> >  > can't
> >  > >  have
> >  > >
> >  > >  <t:flexDateEditor name="prop:context.controlName" ... />
> >  > >
> >  > >  !
> >  > >
> >  > >  Bill
> >  > >
> >  > >
> >  > >  On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <
> hlship@gmail.com>
> >  > wrote:
> >  > >
> >  > >
> >  > >
> >  > > > Hard to tell without checking the code, but:  looks like the
> >  > >  > FlexDataEditor delegates all its behavior to the built-in
> DateField
> >  > >  > component, right?
> >  > >  >
> >  > >  > So the DateField is the component that (at render) negotiates an
> >  > >  > control name (i.e., FormSupport.allocateControlName() ), and
> then
> >  > >  > pushes the parsed and validated date back up.  You should see
> this in
> >  > >  > the HTML and form submission, a component whose client element
> has a
> >  > >  > name like "datefield" (or "datefield_0", etc.).
> >  > >  >
> >  > >  > Presumable the DateField is tied to a property of the
> FlexDateEditor,
> >  > >  > and that property is tied eventually up to your bean.
> >  > >  >
> >  > >  > On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <
> bill@peoplepad.com>
> >  > wrote:
> >  > >  > > I've got a custom data type called FlexDate, and I've made a
> simple
> >  > >  > >  <t:flexdateeditor> component for it which (for now) just
> holds a
> >  > date
> >  > >  > >  field.  It will get more complex later.  I put this editor
> into my
> >  > >  > >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a
> data
> >  > object
> >  > >  > with
> >  > >  > >  an instance var of FlexDate type.  I pump this into a
> >  > beanformeditor.
> >  > >  >  The
> >  > >  > >  problem is that the elementName arg of processSubmission (in
> >  > >  > >  FlexDateEditor.java) never seems to be in my
> >  > >  > _request.getParameterNames() so
> >  > >  > >  I can extract the date!  Help?
> >  > >  > >
> >  > >  > >  FlexDateEditor.tml:
> >  > >  > >
> >  > >  > >  <div class="flexDateEditor" xmlns:t="
> >  > >  > >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> >  > >  > >
> >  > >  > >     <t:dateField value="date1" />
> >  > >  > >
> >  > >  > >  </div>
> >  > >  > >
> >  > >  > >  Date1 is defined in FlexDateEditor.java and evaluated to new
> >  > Date()
> >  > >  > during
> >  > >  > >  beginRender().
> >  > >  > >
> >  > >  > >  AppPropertyEditBlocks.tml (snippet):
> >  > >  > >
> >  > >  > >  <t:block t:id="flexDate">
> >  > >  > >
> >  > >  > >         <t:label for="flexDateEditor" />
> >  > >  > >         <t:flexDateEditor t:id="flexDateEditor" />
> >  > >  > >
> >  > >  > >  </t:block>
> >  > >  > >
> >  > >  > >  The elementName arg of processSubmission in
> FlexDateEditor.java is
> >  > >  > always
> >  > >  > >  the name of the instance variable in my data object that goes
> into
> >  > >  > >  beanformeditor.  Grr.  How can I get the fields of the
> datefield
> >  > to be
> >  > >  > named
> >  > >  > >  that way so I can extract the value?
> >  > >  > >
> >  > >  > >  --
> >  > >  > >  Bill @ PeoplePad
> >  > >  > >
> >  > >  >
> >  > >  >
> >  > >  >
> >  > >  > --
> >  > >  > Howard M. Lewis Ship
> >  > >  >
> >  > >  > Creator Apache Tapestry and Apache HiveMind
> >  > >  >
> >  > >
> >  > >
> >  > > >
> ---------------------------------------------------------------------
> >  > >  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  > >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  > >  >
> >  > >  >
> >  > >
> >  > >
> >  > >  --
> >  > >  Bill @ PeoplePad
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > Howard M. Lewis Ship
> >  >
> >  > Creator Apache Tapestry and Apache HiveMind
> >  >
> >  > ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  >
> >  >
> >
> >
> >  --
> >  Bill @ PeoplePad
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Howard Lewis Ship <hl...@gmail.com>.
Do you still have a DateField inside your FlexDateField?  Could you
show the full template and the HTML output?  I think we're not quite
hooking up here.

On Wed, Apr 16, 2008 at 7:16 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> If I add "_0" to elementName, I'm fine.  But that's fairly brittle :)
>
>
>
>  On Wed, Apr 16, 2008 at 8:47 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
>
>  > Well, binding the clientId parameter of DateField can influence what
>  > the control name will be (though it will be uniqued).
>  >
>  > I still don't understand exactly what you are going to pull out of the
>  > request inside the FlexDateEditor's processSubmission().
>  >
>  > The DateField is almost undoubtedly scheduled as the next component to
>  > process the submission (its basically render order, and the
>  > FlexDateField will render before the DateField because the DateField
>  > is embedded inside the FlexDateField).
>  >
>  > The DateField will update its value parameter, which is bound to the,
>  > well something we haven't seen.
>  >
>  > Perhaps what you need is a callback for *after* the embedded DateField
>  > has done its part, and shoved a value into some property of the
>  > FlexDateField?
>  >
>  >
>  > On Wed, Apr 16, 2008 at 6:14 PM, Bill Holloway <bi...@peoplepad.com> wrote:
>  > > I guess one way to look at it is that in AppPropertyEditBlocks.java, I
>  > can't
>  > >  have
>  > >
>  > >  <t:flexDateEditor name="prop:context.controlName" ... />
>  > >
>  > >  !
>  > >
>  > >  Bill
>  > >
>  > >
>  > >  On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <hl...@gmail.com>
>  > wrote:
>  > >
>  > >
>  > >
>  > > > Hard to tell without checking the code, but:  looks like the
>  > >  > FlexDataEditor delegates all its behavior to the built-in DateField
>  > >  > component, right?
>  > >  >
>  > >  > So the DateField is the component that (at render) negotiates an
>  > >  > control name (i.e., FormSupport.allocateControlName() ), and then
>  > >  > pushes the parsed and validated date back up.  You should see this in
>  > >  > the HTML and form submission, a component whose client element has a
>  > >  > name like "datefield" (or "datefield_0", etc.).
>  > >  >
>  > >  > Presumable the DateField is tied to a property of the FlexDateEditor,
>  > >  > and that property is tied eventually up to your bean.
>  > >  >
>  > >  > On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com>
>  > wrote:
>  > >  > > I've got a custom data type called FlexDate, and I've made a simple
>  > >  > >  <t:flexdateeditor> component for it which (for now) just holds a
>  > date
>  > >  > >  field.  It will get more complex later.  I put this editor into my
>  > >  > >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data
>  > object
>  > >  > with
>  > >  > >  an instance var of FlexDate type.  I pump this into a
>  > beanformeditor.
>  > >  >  The
>  > >  > >  problem is that the elementName arg of processSubmission (in
>  > >  > >  FlexDateEditor.java) never seems to be in my
>  > >  > _request.getParameterNames() so
>  > >  > >  I can extract the date!  Help?
>  > >  > >
>  > >  > >  FlexDateEditor.tml:
>  > >  > >
>  > >  > >  <div class="flexDateEditor" xmlns:t="
>  > >  > >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>  > >  > >
>  > >  > >     <t:dateField value="date1" />
>  > >  > >
>  > >  > >  </div>
>  > >  > >
>  > >  > >  Date1 is defined in FlexDateEditor.java and evaluated to new
>  > Date()
>  > >  > during
>  > >  > >  beginRender().
>  > >  > >
>  > >  > >  AppPropertyEditBlocks.tml (snippet):
>  > >  > >
>  > >  > >  <t:block t:id="flexDate">
>  > >  > >
>  > >  > >         <t:label for="flexDateEditor" />
>  > >  > >         <t:flexDateEditor t:id="flexDateEditor" />
>  > >  > >
>  > >  > >  </t:block>
>  > >  > >
>  > >  > >  The elementName arg of processSubmission in FlexDateEditor.java is
>  > >  > always
>  > >  > >  the name of the instance variable in my data object that goes into
>  > >  > >  beanformeditor.  Grr.  How can I get the fields of the datefield
>  > to be
>  > >  > named
>  > >  > >  that way so I can extract the value?
>  > >  > >
>  > >  > >  --
>  > >  > >  Bill @ PeoplePad
>  > >  > >
>  > >  >
>  > >  >
>  > >  >
>  > >  > --
>  > >  > Howard M. Lewis Ship
>  > >  >
>  > >  > Creator Apache Tapestry and Apache HiveMind
>  > >  >
>  > >
>  > >
>  > > > ---------------------------------------------------------------------
>  > >  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  > >  > For additional commands, e-mail: users-help@tapestry.apache.org
>  > >  >
>  > >  >
>  > >
>  > >
>  > >  --
>  > >  Bill @ PeoplePad
>  > >
>  >
>  >
>  >
>  > --
>  > Howard M. Lewis Ship
>  >
>  > Creator Apache Tapestry and Apache HiveMind
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  > For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>
>
>  --
>  Bill @ PeoplePad
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Bill Holloway <bi...@peoplepad.com>.
If I add "_0" to elementName, I'm fine.  But that's fairly brittle :)

On Wed, Apr 16, 2008 at 8:47 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> Well, binding the clientId parameter of DateField can influence what
> the control name will be (though it will be uniqued).
>
> I still don't understand exactly what you are going to pull out of the
> request inside the FlexDateEditor's processSubmission().
>
> The DateField is almost undoubtedly scheduled as the next component to
> process the submission (its basically render order, and the
> FlexDateField will render before the DateField because the DateField
> is embedded inside the FlexDateField).
>
> The DateField will update its value parameter, which is bound to the,
> well something we haven't seen.
>
> Perhaps what you need is a callback for *after* the embedded DateField
> has done its part, and shoved a value into some property of the
> FlexDateField?
>
>
> On Wed, Apr 16, 2008 at 6:14 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> > I guess one way to look at it is that in AppPropertyEditBlocks.java, I
> can't
> >  have
> >
> >  <t:flexDateEditor name="prop:context.controlName" ... />
> >
> >  !
> >
> >  Bill
> >
> >
> >  On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <hl...@gmail.com>
> wrote:
> >
> >
> >
> > > Hard to tell without checking the code, but:  looks like the
> >  > FlexDataEditor delegates all its behavior to the built-in DateField
> >  > component, right?
> >  >
> >  > So the DateField is the component that (at render) negotiates an
> >  > control name (i.e., FormSupport.allocateControlName() ), and then
> >  > pushes the parsed and validated date back up.  You should see this in
> >  > the HTML and form submission, a component whose client element has a
> >  > name like "datefield" (or "datefield_0", etc.).
> >  >
> >  > Presumable the DateField is tied to a property of the FlexDateEditor,
> >  > and that property is tied eventually up to your bean.
> >  >
> >  > On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com>
> wrote:
> >  > > I've got a custom data type called FlexDate, and I've made a simple
> >  > >  <t:flexdateeditor> component for it which (for now) just holds a
> date
> >  > >  field.  It will get more complex later.  I put this editor into my
> >  > >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data
> object
> >  > with
> >  > >  an instance var of FlexDate type.  I pump this into a
> beanformeditor.
> >  >  The
> >  > >  problem is that the elementName arg of processSubmission (in
> >  > >  FlexDateEditor.java) never seems to be in my
> >  > _request.getParameterNames() so
> >  > >  I can extract the date!  Help?
> >  > >
> >  > >  FlexDateEditor.tml:
> >  > >
> >  > >  <div class="flexDateEditor" xmlns:t="
> >  > >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> >  > >
> >  > >     <t:dateField value="date1" />
> >  > >
> >  > >  </div>
> >  > >
> >  > >  Date1 is defined in FlexDateEditor.java and evaluated to new
> Date()
> >  > during
> >  > >  beginRender().
> >  > >
> >  > >  AppPropertyEditBlocks.tml (snippet):
> >  > >
> >  > >  <t:block t:id="flexDate">
> >  > >
> >  > >         <t:label for="flexDateEditor" />
> >  > >         <t:flexDateEditor t:id="flexDateEditor" />
> >  > >
> >  > >  </t:block>
> >  > >
> >  > >  The elementName arg of processSubmission in FlexDateEditor.java is
> >  > always
> >  > >  the name of the instance variable in my data object that goes into
> >  > >  beanformeditor.  Grr.  How can I get the fields of the datefield
> to be
> >  > named
> >  > >  that way so I can extract the value?
> >  > >
> >  > >  --
> >  > >  Bill @ PeoplePad
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > Howard M. Lewis Ship
> >  >
> >  > Creator Apache Tapestry and Apache HiveMind
> >  >
> >
> >
> > > ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  >
> >  >
> >
> >
> >  --
> >  Bill @ PeoplePad
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Bill Holloway <bi...@peoplepad.com>.
Well, I've got this simplified down a lot.  Forget the beaneditform and
apppropertyedit block.  Here we go:  TestPage.tml has

<t:form t:id="myForm">
        <t:flexDateEditor t:id="theDateEditor" flexDate="myFlexDate" />
        <br />
        <input type="submit" />
    </t:form>

I construct a proper FlexDate for myFlexDate in testpage.java.  There is no
no-arg constructor for flexdate.  Flex date editor looks like this:


public class FlexDateEditor extends AbstractField
{
    @Parameter
    @Property (write = false)
    private FlexDate _flexDate;

    @Inject
    private Request _request;

    @Property
    private Date _date;

    void setupRender ()
    {
        _date = new Date();
    }

    protected void processSubmission (String elementName)
    {
        String dateStr = _request.getParameter( elementName );
        // setup outbound param value
        _flexDate = // constructor using dateStr.
    }
}

<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <t:datefield value="date" />
</t:container>

Question now is what elementName is given.  It's not in the params.  I don't
think extending abstractfield causes a problem.

On Wed, Apr 16, 2008 at 8:47 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> Well, binding the clientId parameter of DateField can influence what
> the control name will be (though it will be uniqued).
>
> I still don't understand exactly what you are going to pull out of the
> request inside the FlexDateEditor's processSubmission().
>
> The DateField is almost undoubtedly scheduled as the next component to
> process the submission (its basically render order, and the
> FlexDateField will render before the DateField because the DateField
> is embedded inside the FlexDateField).
>
> The DateField will update its value parameter, which is bound to the,
> well something we haven't seen.
>
> Perhaps what you need is a callback for *after* the embedded DateField
> has done its part, and shoved a value into some property of the
> FlexDateField?
>
>
> On Wed, Apr 16, 2008 at 6:14 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> > I guess one way to look at it is that in AppPropertyEditBlocks.java, I
> can't
> >  have
> >
> >  <t:flexDateEditor name="prop:context.controlName" ... />
> >
> >  !
> >
> >  Bill
> >
> >
> >  On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <hl...@gmail.com>
> wrote:
> >
> >
> >
> > > Hard to tell without checking the code, but:  looks like the
> >  > FlexDataEditor delegates all its behavior to the built-in DateField
> >  > component, right?
> >  >
> >  > So the DateField is the component that (at render) negotiates an
> >  > control name (i.e., FormSupport.allocateControlName() ), and then
> >  > pushes the parsed and validated date back up.  You should see this in
> >  > the HTML and form submission, a component whose client element has a
> >  > name like "datefield" (or "datefield_0", etc.).
> >  >
> >  > Presumable the DateField is tied to a property of the FlexDateEditor,
> >  > and that property is tied eventually up to your bean.
> >  >
> >  > On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com>
> wrote:
> >  > > I've got a custom data type called FlexDate, and I've made a simple
> >  > >  <t:flexdateeditor> component for it which (for now) just holds a
> date
> >  > >  field.  It will get more complex later.  I put this editor into my
> >  > >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data
> object
> >  > with
> >  > >  an instance var of FlexDate type.  I pump this into a
> beanformeditor.
> >  >  The
> >  > >  problem is that the elementName arg of processSubmission (in
> >  > >  FlexDateEditor.java) never seems to be in my
> >  > _request.getParameterNames() so
> >  > >  I can extract the date!  Help?
> >  > >
> >  > >  FlexDateEditor.tml:
> >  > >
> >  > >  <div class="flexDateEditor" xmlns:t="
> >  > >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> >  > >
> >  > >     <t:dateField value="date1" />
> >  > >
> >  > >  </div>
> >  > >
> >  > >  Date1 is defined in FlexDateEditor.java and evaluated to new
> Date()
> >  > during
> >  > >  beginRender().
> >  > >
> >  > >  AppPropertyEditBlocks.tml (snippet):
> >  > >
> >  > >  <t:block t:id="flexDate">
> >  > >
> >  > >         <t:label for="flexDateEditor" />
> >  > >         <t:flexDateEditor t:id="flexDateEditor" />
> >  > >
> >  > >  </t:block>
> >  > >
> >  > >  The elementName arg of processSubmission in FlexDateEditor.java is
> >  > always
> >  > >  the name of the instance variable in my data object that goes into
> >  > >  beanformeditor.  Grr.  How can I get the fields of the datefield
> to be
> >  > named
> >  > >  that way so I can extract the value?
> >  > >
> >  > >  --
> >  > >  Bill @ PeoplePad
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > Howard M. Lewis Ship
> >  >
> >  > Creator Apache Tapestry and Apache HiveMind
> >  >
> >
> >
> > > ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  > For additional commands, e-mail: users-help@tapestry.apache.org
> >  >
> >  >
> >
> >
> >  --
> >  Bill @ PeoplePad
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Howard Lewis Ship <hl...@gmail.com>.
Well, binding the clientId parameter of DateField can influence what
the control name will be (though it will be uniqued).

I still don't understand exactly what you are going to pull out of the
request inside the FlexDateEditor's processSubmission().

The DateField is almost undoubtedly scheduled as the next component to
process the submission (its basically render order, and the
FlexDateField will render before the DateField because the DateField
is embedded inside the FlexDateField).

The DateField will update its value parameter, which is bound to the,
well something we haven't seen.

Perhaps what you need is a callback for *after* the embedded DateField
has done its part, and shoved a value into some property of the
FlexDateField?


On Wed, Apr 16, 2008 at 6:14 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> I guess one way to look at it is that in AppPropertyEditBlocks.java, I can't
>  have
>
>  <t:flexDateEditor name="prop:context.controlName" ... />
>
>  !
>
>  Bill
>
>
>  On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
>
>
>
> > Hard to tell without checking the code, but:  looks like the
>  > FlexDataEditor delegates all its behavior to the built-in DateField
>  > component, right?
>  >
>  > So the DateField is the component that (at render) negotiates an
>  > control name (i.e., FormSupport.allocateControlName() ), and then
>  > pushes the parsed and validated date back up.  You should see this in
>  > the HTML and form submission, a component whose client element has a
>  > name like "datefield" (or "datefield_0", etc.).
>  >
>  > Presumable the DateField is tied to a property of the FlexDateEditor,
>  > and that property is tied eventually up to your bean.
>  >
>  > On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com> wrote:
>  > > I've got a custom data type called FlexDate, and I've made a simple
>  > >  <t:flexdateeditor> component for it which (for now) just holds a date
>  > >  field.  It will get more complex later.  I put this editor into my
>  > >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data object
>  > with
>  > >  an instance var of FlexDate type.  I pump this into a beanformeditor.
>  >  The
>  > >  problem is that the elementName arg of processSubmission (in
>  > >  FlexDateEditor.java) never seems to be in my
>  > _request.getParameterNames() so
>  > >  I can extract the date!  Help?
>  > >
>  > >  FlexDateEditor.tml:
>  > >
>  > >  <div class="flexDateEditor" xmlns:t="
>  > >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>  > >
>  > >     <t:dateField value="date1" />
>  > >
>  > >  </div>
>  > >
>  > >  Date1 is defined in FlexDateEditor.java and evaluated to new Date()
>  > during
>  > >  beginRender().
>  > >
>  > >  AppPropertyEditBlocks.tml (snippet):
>  > >
>  > >  <t:block t:id="flexDate">
>  > >
>  > >         <t:label for="flexDateEditor" />
>  > >         <t:flexDateEditor t:id="flexDateEditor" />
>  > >
>  > >  </t:block>
>  > >
>  > >  The elementName arg of processSubmission in FlexDateEditor.java is
>  > always
>  > >  the name of the instance variable in my data object that goes into
>  > >  beanformeditor.  Grr.  How can I get the fields of the datefield to be
>  > named
>  > >  that way so I can extract the value?
>  > >
>  > >  --
>  > >  Bill @ PeoplePad
>  > >
>  >
>  >
>  >
>  > --
>  > Howard M. Lewis Ship
>  >
>  > Creator Apache Tapestry and Apache HiveMind
>  >
>
>
> > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  > For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>
>
>  --
>  Bill @ PeoplePad
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Bill Holloway <bi...@peoplepad.com>.
I guess one way to look at it is that in AppPropertyEditBlocks.java, I can't
have

<t:flexDateEditor name="prop:context.controlName" ... />

!

Bill

On Wed, Apr 16, 2008 at 6:21 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> Hard to tell without checking the code, but:  looks like the
> FlexDataEditor delegates all its behavior to the built-in DateField
> component, right?
>
> So the DateField is the component that (at render) negotiates an
> control name (i.e., FormSupport.allocateControlName() ), and then
> pushes the parsed and validated date back up.  You should see this in
> the HTML and form submission, a component whose client element has a
> name like "datefield" (or "datefield_0", etc.).
>
> Presumable the DateField is tied to a property of the FlexDateEditor,
> and that property is tied eventually up to your bean.
>
> On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> > I've got a custom data type called FlexDate, and I've made a simple
> >  <t:flexdateeditor> component for it which (for now) just holds a date
> >  field.  It will get more complex later.  I put this editor into my
> >  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data object
> with
> >  an instance var of FlexDate type.  I pump this into a beanformeditor.
>  The
> >  problem is that the elementName arg of processSubmission (in
> >  FlexDateEditor.java) never seems to be in my
> _request.getParameterNames() so
> >  I can extract the date!  Help?
> >
> >  FlexDateEditor.tml:
> >
> >  <div class="flexDateEditor" xmlns:t="
> >  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> >
> >     <t:dateField value="date1" />
> >
> >  </div>
> >
> >  Date1 is defined in FlexDateEditor.java and evaluated to new Date()
> during
> >  beginRender().
> >
> >  AppPropertyEditBlocks.tml (snippet):
> >
> >  <t:block t:id="flexDate">
> >
> >         <t:label for="flexDateEditor" />
> >         <t:flexDateEditor t:id="flexDateEditor" />
> >
> >  </t:block>
> >
> >  The elementName arg of processSubmission in FlexDateEditor.java is
> always
> >  the name of the instance variable in my data object that goes into
> >  beanformeditor.  Grr.  How can I get the fields of the datefield to be
> named
> >  that way so I can extract the value?
> >
> >  --
> >  Bill @ PeoplePad
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Bill @ PeoplePad

Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Howard Lewis Ship <hl...@gmail.com>.
Hard to tell without checking the code, but:  looks like the
FlexDataEditor delegates all its behavior to the built-in DateField
component, right?

So the DateField is the component that (at render) negotiates an
control name (i.e., FormSupport.allocateControlName() ), and then
pushes the parsed and validated date back up.  You should see this in
the HTML and form submission, a component whose client element has a
name like "datefield" (or "datefield_0", etc.).

Presumable the DateField is tied to a property of the FlexDateEditor,
and that property is tied eventually up to your bean.

On Wed, Apr 16, 2008 at 3:42 PM, Bill Holloway <bi...@peoplepad.com> wrote:
> I've got a custom data type called FlexDate, and I've made a simple
>  <t:flexdateeditor> component for it which (for now) just holds a date
>  field.  It will get more complex later.  I put this editor into my
>  AppPropertyEditBlocks.tml.  Code is below.  Then I have a data object with
>  an instance var of FlexDate type.  I pump this into a beanformeditor.  The
>  problem is that the elementName arg of processSubmission (in
>  FlexDateEditor.java) never seems to be in my _request.getParameterNames() so
>  I can extract the date!  Help?
>
>  FlexDateEditor.tml:
>
>  <div class="flexDateEditor" xmlns:t="
>  http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>
>     <t:dateField value="date1" />
>
>  </div>
>
>  Date1 is defined in FlexDateEditor.java and evaluated to new Date() during
>  beginRender().
>
>  AppPropertyEditBlocks.tml (snippet):
>
>  <t:block t:id="flexDate">
>
>         <t:label for="flexDateEditor" />
>         <t:flexDateEditor t:id="flexDateEditor" />
>
>  </t:block>
>
>  The elementName arg of processSubmission in FlexDateEditor.java is always
>  the name of the instance variable in my data object that goes into
>  beanformeditor.  Grr.  How can I get the fields of the datefield to be named
>  that way so I can extract the value?
>
>  --
>  Bill @ PeoplePad
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: BeanForm, processSubmission, AppPropertyEditBlock help

Posted by Peter Beshai <pe...@gmail.com>.
Not sure if this is the best approach, but it might work: try adding a
clientId parameter to FlexDate and forwarding it to the date field. Sorry, I
haven't tested it!

FlexDate.tml:
<div class="flexDateEditor" xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
   <t:dateField value="date1" clientId="prop:clientId"/>
</div>

FlexDate.java:
@Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
@Property // so I don't have to write out the getters/setters ;>
private String _clientId;

AppPropertyEditBlocks.tml (snippet):
<t:block t:id="flexDate">
       <t:label for="flexDateEditor" />
       <t:flexDateEditor t:id="flexDateEditor"
clientId="prop:context.propertyId" />
</t:block>

AppPropertyEditBlocks.java:
@Environment
@Property
private PropertyEditContext _context;


On Wed, Apr 16, 2008 at 6:42 PM, Bill Holloway <bi...@peoplepad.com> wrote:

> I've got a custom data type called FlexDate, and I've made a simple
> <t:flexdateeditor> component for it which (for now) just holds a date
> field.  It will get more complex later.  I put this editor into my
> AppPropertyEditBlocks.tml.  Code is below.  Then I have a data object with
> an instance var of FlexDate type.  I pump this into a beanformeditor.  The
> problem is that the elementName arg of processSubmission (in
> FlexDateEditor.java) never seems to be in my _request.getParameterNames()
> so
> I can extract the date!  Help?
>
> FlexDateEditor.tml:
>
> <div class="flexDateEditor" xmlns:t="
> http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>
>    <t:dateField value="date1" />
>
> </div>
>
> Date1 is defined in FlexDateEditor.java and evaluated to new Date() during
> beginRender().
>
> AppPropertyEditBlocks.tml (snippet):
>
> <t:block t:id="flexDate">
>
>        <t:label for="flexDateEditor" />
>        <t:flexDateEditor t:id="flexDateEditor" />
>
> </t:block>
>
> The elementName arg of processSubmission in FlexDateEditor.java is always
> the name of the instance variable in my data object that goes into
> beanformeditor.  Grr.  How can I get the fields of the datefield to be
> named
> that way so I can extract the value?
>
> --
> Bill @ PeoplePad
>