You guys are great! Making more sense all the time...

Ok, here is a small remaining problem and it is related to finding the
AppPropertyEditBlocks (tml and java) artifacts. I've included each step here
just to be sure I understand how the fit together. I intentionally left off
the SelectModel for this - as I want to understand that I can do that
'next'. That does mean that I hope the Textfield solution (from the
tutorial) just 'works' for me in this case. Trying to keep the things I'm
adding and changing as incremental as I can.


<shortVersion>
After adding the AppPropertyEdtBlocks.tml and corresponding entries
tocontributeBeanBlockSource, When I visit the List (uses readble block) or
Create and Edit (uses editable block) pages - Tapestry can't seem to find:
AppPropertyEditBlocks.tml

ERROR:

Render queue error in BeginRender[topic/Create:topic.editor.propertyeditor]:
Unable to locate a block to edit property 'classification' (with data type
'classification') of object { Topic { null }}: Unable to resolve
'AppPropertyEditBlocks' to a known page name

Right now - it is under the services directory (alongside AppModule and
AppPropertyEditBlocks.java) and I've confirmed that it is in indeed being
copied out to the target directory.
</shortVersion>



Ok, here we go with the Edit stuff :) To keep this simple, I am happy using
a TextField for now as the online tutorial has. Once I can get this wired up
and working - I can try it with the SelectModel.



1. added src/main/java/${app.home}/services/AppPropertyEditBlocks.java

public class AppPropertyEditBlocks
{
    @Environmental
    private PropertyEditContext context;

    @Component(parameters =
    { "value=context.name", "label=prop:context.label",
"translate=prop:classificationTranslator",
"validate=prop:classificationValidator", "clientId=prop:context.propertyId"
})
    private TextField classification;

    public PropertyEditContext getContext()
    {
        return context;
    }

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

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

context.getTranslator and context.getValidator are not typed (so I get
warning in Eclipse) but otherwise - no errors. I don't exactly know how this
class works yet - or what role it plays but I know it ties in with the
corresponding tml file. I am fine with a simple example for now so I'm just
copying from the online tutorial - using Textfield - I hope 'classification'
works ok as a TextField ... but hoping at least the error can tell me what
to do next. Is there a page that focuses directly or indirectly on this
Class and what it does/needs, etc? For now - I copied. How does context get
all this info? I see the @Component annotation which I've seen docs for ...
I've just not needed it yet. Are those parameters well known and well
documented in places like this
http://tapestry.apache.org/tapestry5/guide/component-classes.html

I'm trying to abstractly match up the arguments to @Component and wondering
to myself "What is context.name ... and do I need a property called
context.label ... and what do I need a translator for ... ". At any rate -
don't spend too much time answering these questions as I will dig deeper for
this. These were just my initial thoughts and if there are some high level
guidelines, I'd appreciate those.



2. Added src/main/resources/${app.home}/services/AppPropertyEditBlocks.java

<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <t:block t:id="readableClassificationBlock">
        This came from AppPropertyEditBlocks.readableClassificationBlock ...
${classification.name}
    </t:block>
    <t:block t:id="editableClassificationBlock">
        This came from AppPropertyEditBlocks.editableClassificationBlock ...
<t:textfield t:id="classification" size="10"/>
    </t:block>
</div>



3. Add contributions to
src/main/resources/${app.home}/services/AppModule.java


    /**
     * Associate keys with data types.
     *
     * @param configuration
     */
    public static void
contributeDefaultDataTypeAnalyzer(MappedConfiguration<Class<?>, String>
config
    {
        config.add(Classification.class, "classification");
    }

    /**
     * Link custom data types to block ids.
     *
     * @param config
     */
    public void
contributeBeanBlockSource(Configuration<BeanBlockContribution> config)
    {
        config.add(new BeanBlockContribution("classification",
"AppPropertyEditBlocks", "readableClassificationBlock", true));
        config.add(new BeanBlockContribution("classification",
"AppPropertyEditBlocks", "editableClassificationBlock", false));
    }



4. Add the page with the t:BeanEditForm,
src/main/resources/${app.home}/pages/topic/CreateTopic.java

<t:Layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <ul class="links">
        <li><t:PageLink page="topic/ListTopics">List
Topics</t:PageLink></li>
        <li><t:PageLink page="topic/CreateTopic">Create
Topic</t:PageLink></li>
    </ul>
    <h2>Edit Topic</h2>
    <t:BeanEditForm t:id="topic" exclude="id,createdOn,modifiedOn"
reorder="name,details,comments,tags,classification" add="delete">
        <t:Parameter name="delete"><t:ActionLink t:Id="Delete" context="
topic.id">Delete</t:ActionLink></t:Parameter>
    </t:BeanEditForm>
</t:Layout>



5. Add another page with the t:BeanEditForm,
src/main/resources/${app.home}/pages/topic/EditTopic.java

<t:Layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <ul class="links">
        <li><t:PageLink page="topic/ListTopics">List Topic</t:PageLink></li>
    </ul>
    <h2>Create Topic</h2>
    <t:BeanEditForm t:id="topic" exclude="id,createdOn,modifiedOn"
reorder="name,details,comments,tags,classification"/>
</t:Layout>



When I visit the CREATE or EDIT pages listed here - it gets closer but can't
seem to find: AppPropertyEditBlocks.tml

ERROR:

Render queue error in BeginRender[topic/Create:topic.editor.propertyeditor]:
Unable to locate a block to edit property 'classification' (with data type
'classification') of object { Topic { null }}: Unable to resolve
'AppPropertyEditBlocks' to a known page name

Right now - it is under the services directory (alongside AppModule and
AppPropertyEditBlocks.java) and I've confirmed that it is in the TARGET
directory.

I really think this is a trivial error ... but I've moved those two files
around to the pages dir, the components dir and the services dir ... but
always the same error. Seems to me my blocks pages isn't getting picked up
... Thoughts?

-Luther


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

> Em Tue, 17 Feb 2009 18:13:51 -0300, Luther Baker <lutherba...@gmail.com>
> escreveu:
>
>  It trickie since it seems that Tapestry could call toString() on anything
>> without requiring this registration step. In this simplistic case,
>> registration didn't really tell it anything. But - given this registration
>> step - a few things make sense like ... before doing this, listing the
>> column name in the reorder clause of a t:grid was throwing an exception.
>>
>
> This exception happened because BeanModelSource didn't create a in a
> BeanModel property for Topic's classification property because it didn't
> know the Tapestry type for the Classification class. It's a very different
> issue.
>
>  :) One day - I hope to contribute BACK to Tapestry and than ... will have
>> arrived.
>>
>
> Everybody needs help and everybody can help. :)
> I didn't know that just providing a Tapestry type for a class would make
> BeanModelSource handle it. I learned something today. :)
>
>  Thanks for your timely input. One last post on the way.
>>
>
> You're welcome! :)
>
> --
> 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