Got it! I can see my blocks rendering appropriately for both editable and
non-editable fields.

To come full circle, I need to better understand AppPropertyEditBlock.java.

I had to strip a few parameters out and print literals for now. My next
question ... is how to get MY data into that class.

public class AppPropertyEditBlocks
{
    @Environmental
    private PropertyEditContext context;

    @Property
    @Component(parameters =
    { "value=literal:cool class" })
    private TextField classification;

    public PropertyEditContext getContext()
    {
        return context;
    }

    public FieldValidator<Classification> getClassificationValidator()
    {
        return context.getValidator(classification);
    }

    public FieldTranslator<Classification> getClassificationTranslator()
    {
        return context.getTranslator(classification);
    }
}


<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:block t:id="readableClassificationBlock">
        This came from AppPropertyEditBlocks.readableClassificationBlock ...

    </t:block>
    <t:block t:id="editableClassificationBlock">
        This came from AppPropertyEditBlocks.editableClassificationBlock ...
<t:textfield t:id="classification" size="10"/>
    </t:block>
</div>

This works - but obviously puts "cool class" into the textfield.

Incremental changes:

<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:block t:id="readableClassificationBlock">
        This came from AppPropertyEditBlocks.readableClassificationBlock ...

    </t:block>
    <t:block t:id="editableClassificationBlock">
        This came from AppPropertyEditBlocks.editableClassificationBlock ...
<t:textfield t:id="classification" size="10"/>
    </t:block>
</div>

Errors with: Component AppPropertyEditBlocks already contains a child
component with id 'classification'. Embedded component ids must be unique
(excluding case, which is ignored).

Ah - (#1) I thought this was going to work - since only one or the other
block would be used at any given time. Since we are using the same java
class for either / or block ... it strikes me that I can't reuse t:id. Does
the corresponding Java class somehow discriminate and use my same
classification property object but with multiple ids? I think I'm confusing
things - partly because I have little component writing experience.

(#2) mm ... how do I get ahold of my Classification value ;) I think it must
have something to do with the PropertyEditContext but changes like this

    @Property
    @Component(parameters =
    { "value=context.propertyValue",
"translate=prop:classificationTranslator" })
    private TextField classification;

aren't quite enough. the DISPLAY block works just fine (no property is in
that block) but when using the BeanEditForm, I get an error: "Parameter
'translate' of component AppPropertyEditBlocks:classification is bound to
null. This parameter is not allowed to be null." I think that error must be
related to the method

    public FieldTranslator<Classification> getClassificationTranslator()
    {
        return context.getTranslator(classification);
    }

but I'm not sure what to do to get that working. What is a 'translator' and
how do I write one ... and attach it to the context? And ... are those
appropriate questions?

As a side note, my guess is that PropertyEditContext magically encapsulates
the 'classification' object I am trying to render. I tried this

    @Component(parameters =
    { "value=context.propertyValue.*name*",
"translate=prop:classificationTranslator" })

but that didn't turn out so well. "Could not convert '
context.propertyValue.name' into a component parameter binding: Class
java.lang.Object does not contain a property named 'name' (within property
expression 'context.propertyValue.name'). Available properties: class."

Thoughts? Maybe how does my "Classification" object get here ... and how do
I access it's properties ... and how do I attach translator ... or even a
validator if I've not defined one?

Thanks again,

-Luther



On Tue, Feb 17, 2009 at 3:47 PM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> Em Tue, 17 Feb 2009 18:42:22 -0300, Luther Baker <lutherba...@gmail.com>
> escreveu:
>
>  You guys are great! Making more sense all the time...
>>
>
> You have just said nonsense! :p
>
>  Create and Edit (uses editable block) pages - Tapestry can't seem to find:
>> AppPropertyEditBlocks.tml
>>
>
> AppPropertyEditBlocks, or any other name you fancy, is an ordinary page
> (besides the fact that it won't be used to render HTML), so it must be its
> own class, located at the *pages* package. It's tml file should be at the
> same place you put your 'real' page templates.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to