-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

With regard to parameters on components.  I want to be able to pass an object 
reference into a component. I'm having a few "issues" doing this.

I feel it's only right to give a reasonable amount of detail in order that 
people understand the environment, so I hope that you do not mind a long 
post.

This situation involves a single page called ContentManager and a component 
called SimpleContentEditor. The ContentManager is capable of showing a list 
of content, allowing the user to select one, and edit it.  The editing itself 
is done with a SimpleContentEditor component.

The object being edited is stored in a Visit object, with bean property 
"currentContent". The idea is the the ContentManager page can set the visit 
property to something (either an existing object, or a new one) - the 
SimpleContentEditor component changes it - and then commits the object (the 
content objects are Cayenne based).

My problem is that I am seeing weird behavior in the content editor - only 
when Tapestry is run WITH caching (its default state). I think my problem 
boils down to a misunderstanding in the way property bindings work, and when 
I should make use of them etc.  Hopefully someone can set me right!!!

Here's what I do currently:
The ContentManager page can display either the list, or the 
SimpleContentEditor component, since it has an HTML with Conditional 
components like this:

        <span jwcid="modeSelect">
                ... other stuff here ...
        </span>
        
        <span jwcid="modeEdit">
                <span jwcid="contentEditor"/>
        </span>

When modeSelect is true, the content list is shown. When the user clicks to 
edit content the page can setup an object in visit.currentContent, and make 
it such that modeSelect would be false, and modeEdit would be true. I did 
this purely so that I didn't have to create another page for the content 
editor. Don't know if it's a generally bad thing or not. Anyway, onwards...

The ContentManager page binds the content editor component as follows:

    <component id="contentEditor" type="SimpleContentEditor">
        <binding name="content" expression='visit.currentContent'/>
        <binding name="delegate" expression='beans.delegate'/>
    </component>

The page is then reshown, which will show the content editor. The Component 
specification for SimpleContentEditor looks like this:

   <parameter
        name="content"
        java-type="tcdc.website.common.content.Content"
        direction="custom"
        required="yes">
        <description><![CDATA[   A single Content instance   ]]></description>
    </parameter>

    <component id="content" type="TextArea">
        <static-binding name="columns">60</static-binding>
        <static-binding name="rows">15</static-binding>
        <binding name="value" expression='content.content'/>
    </component>

        .... (more fields exist but have been cut out for brevity)

The way I understand things, the following should happen:
1. Tapestry sets the paramters of the page up, within IBinding instances
2. The input value "content" is therefore really bound to visit.currentContent 
(because of the specification on ComponentManager)
3. Tapestry will render the page using values from the object currently stored 
in visit.currentContent.
4. When the page is submitted, changes in the fields will be made to the 
object referenced by visit.currentContent, by the field bindings 

What I observe is not quite the case.  When the page renders, I get an 
exception "Unable to resolve expression 'content.category' for 
tcdc.dataarmour.website.components.SimpleContentEditor@1c783c5[ContentMgr/contentEditor]."
 
unless I change my getContent() method to:

        public Content getContent() {
                if (content == null) {
                        cat.debug("Setting up content from binding - it's currently 
null");
                        IBinding binding = getBinding("content");
                        content = (Content) binding.getObject();
                }
                return content;
        }

Then the page will show, but I get other kinds of problems when adding new 
content after having editing existing content. This current email is quite 
long enough, so I would first like to ask:

Is the way that I have done the binding within SimpleContentEditor correct?

I've just got a private instance "content", which has accessor methods 
(getContent is shown above). setContent() just sets the var, but does not 
call fireObservedChange because that causes a problem.

If you have got this far, thank you for reading this! I hope I have given 
sufficient detail to get across my problem.

Regards,
Neil Clayton

(PS: If you see strange text you don't understand underneath my email, don't 
worry - it's just my PGP signature)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE91n7lLXcfQF3yrNoRAqSnAJ9pZ6sKMBRofbsCqV9toamJzFshjQCePLbj
SQK0xwnEmOeOImq0Fm67RUc=
=TvJs
-----END PGP SIGNATURE-----



-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to