I think I'm on the right track, but I still need a little guidance.

I'm getting problems when trying to render my component.  I'm getting
an org.apache.tapestry.BindingException with the message:
Value for parameter 'model' in component BreadCrumbPage/nav.chooser is
null, and a non-null value is required.

The parameter 'model' is the model for the PropertySelection component
within my BreadCrumb component.

To use the BreadCrumbs component, I define it like this in my .page file:

    <property-specification name="source"
        persistent="yes"
        type="org.jk.tapestryutils.components.breadcrumbs.IBreadCrumbSource"/>
    <component id="nav" type="taputil:BreadCrumbs">
        <binding name="source" expression="source"/>
        <binding name="homeTitle" expression="'Home'"/>
        <binding name="delimiter" expression="' > '"/>
    </component>


IBreadCrumbSource defines one method, which is loadChildrenOf( int i).
 The BreadCrumbs component uses this to populate the dropdown. So I
tried doing a lazy initialization in the prepareForRender method:

    if (getModel() == null)
    {
      setModel(new
ValueStringPropertySelectionModel(getSource().loadChildrenOf(0)));
    }

but the 'source' object is null.  How do I tell my component to use
the source object that is defined in the .page file?



I don't know if this is needed but I'll post it anyway:

BreadCrumbs.jwc:
<component-specification allow-body="no"
    allow-informal-parameters="no"
    class="org.jk.tapestryutils.components.breadcrumbs.BreadCrumbs">
    
    <parameter name="homeTitle"
        direction="in"
        required="yes"
        type="java.lang.String"/>
        
    <parameter name="source"
        direction="in"
        required="yes"
        type="org.jk.tapestryutils.components.breadcrumbs.IBreadCrumbSource"/>
        
    <parameter name="delimiter"
        required="yes"
        direction="in"
        type="java.lang.String"/>
        
        
    
    <property-specification name="values"
        persistent="yes"
        type="java.util.List"/>
    
    <property-specification name="selected"
        persistent="yes"
        type="org.jk.tapestryutils.form.IValueString"/>
        
    <property-specification name="model"
        persistent="yes"
        type="org.jk.tapestryutils.form.ValueStringPropertySelectionModel" />
    
    <property-specification name="currentValue"
        type="org.jk.tapestryutils.form.IValueString"/>
        
        
    <component id="homeLink" type="DirectLink">
        <binding name="listener" expression="navHome"/>
    </component>
    <component id="homeTitle" type="Insert">
        <binding name="value" expression="homeTitle"/>
    </component>
    <component id="ancestorLink" type="LinkSubmit">
        <binding name="listener" expression="navLink"/>
        <binding name="selected" expression="selected"/>
        <binding name="tag" expression="currentValue"/>
    </component>
    <component id="ancestors" type="Foreach">
        <binding name="source" expression="values"/>
        <binding name="value" expression="currentValue"/>
    </component>
    <component id="ancestor" type="Insert">
        <binding name="value" expression="currentValue.name"/>
    </component>
    <component id="delimit" type="Insert">
        <binding name="value" expression="delimiter"/>
    </component>
    <component id="chooser" type="PropertySelection">
        <binding name="value" expression="selected"/>
        <binding name="model" expression="model"/>
    </component>
    <component id="goButton" type="Submit">
        <binding name="value" expression="'Go'"/>
        <binding name="listener" expression="navGo"/>
    </component>
</component-specification>


Thanks,
  Jer





On 7/27/05, Robert Zeigler <[EMAIL PROTECTED]> wrote:
> You do it exactly like in a page.
> Extend BaseComponent, specify the extended class as your component class
> in the .jwc file. Define your listeners methods in your component class.
> In your component, anywhere you're adding listeners, just do
> ognl:listeners.<listenername>
> And that's it. Your page never has to worry about there being listeners
> in the component.
> 
> Robert
> 
> Jer Kah wrote:
> > Hello,
> >
> >  I have a simple component that combines several existing components
> > (DirectLinks, a select box and submit button) into one component.
> > I've created an html template and a jwc for it so far, but I think I
> > have to subclass BaseComponent.  The problem I'm having is that
> > whenever I use this component in a page, I have write listener methods
> > for the directLinks (all the directlinks use the same listener) and
> > for the submit button.  I don't want to write these listeners in every
> > page that uses this component.
> >
> > Can I define these listeners in a subclass of BaseComponent?  If so,
> > does someone have a simple example of how to do this?  Right now, I
> > have to bind the listeners for the component in the page file, but
> > these methods will always do the same thing and I don't want to define
> > them in every .page file.
> >
> >
> > Thanks,
> >   Jer
> >
> > ---no need to read further if you're not interested, but it may give
> > you some more insight ----
> >
> >
> > This component is a breadcrumb navigation component.  Our data is very
> > hierarchical, (each row in the db has a 'ParentID' field), so there's
> > a select box at the end of the breadcrumbs so that you can select the
> > next child to go to.
> >
> > It starts off showing one link ( a 'Home' link) , a select box and
> > submit button labelled "Go".   The select box shows all data in the db
> > at the top of the hierarchy.  When you select an option and then hit
> > the "Go" button, another link will be placed next to the Home link and
> > before the select box.
> >
> > Home    |________| V |     |GO|
> >
> >  // pick an option, click "Go" and then it changes to:
> >
> > Home > chosenOption      |________| V |     |GO|
> >
> > As long as there are children to the last option chosen, they will be
> > populated in the select box.  Each of our pages has an associated ID
> > to go along with it (the value of the last chosen option, or 0 if none
> > have been chosen yet).
> >
> > If you click a breadcrumb, the pages' ID will update and all the
> > breadcrumbs after the clicked breadcrumb will go away.
> >
> > As you can see, the listener methods for the links and 'go' button are
> > very well defined and won't be changing.  I hate having to copy and
> > paste the listener methods into each page that wants to use this
> > componnent and I know there must be a better way to do it than this
> > way.  It seems like the component should know how to do this by
> > itself.
> >
> > If you have any ideas or suggestions, please let me know.  I'm new to
> > making components and I don't know the best way forward.
> >
> > Thanks,
> >   Jer
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to