You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim Menard <ji...@io.com> on 2004/02/20 17:09:25 UTC
Solved (Was Re: Multiple copies of a component (class for fields))
Solved! Thank you, Jonny.
I needed to make the component-specification a new class, not a
BaseComponent. The new class does nothing more than hold an instance of
the DateChoices object (the bean with the eight fields).
Then each component needed to use binding normally, not
inherited-binding, with expressions like "choices.year" and
"choices.startDate".
Here's the snippet from the page's .page:
<component id="uploadDateChoices" type="SearchDate">
<binding name="choices" expression="uploadDateChoices"/>
</component>
<component id="origDateChoices" type="SearchDate">
<binding name="choices" expression="origDateChoices"/>
</component>
Here's the part of the component's .jwc:
<component-specification
class="com.preclick.photowiki.tapestry.component.SearchDate"
allow-informal-parameters="no">
<parameter name="choices" required="yes" direction="in"
java-type="com.preclick.photowiki.search.DateChoices"/>
<component id="radioGroup" type="RadioGroup">
<binding name="selected" expression="choices.which"/>
</component>
<!-- ... -->
<component id="endDate" type="DatePicker">
<binding name="value" expression="choices.endDate"/>
</component>
<component id="monthMenu" type="PropertySelection">
<binding name="value" expression="choices.monthEnum"/>
<binding name="model"
expression="@com.preclick.photowiki.tapestry.page.AdvancedSearchPage@MON
TH_MENU_MODEL"/>
</component>
<component id="year" type="TextField">
<binding name="value" expression="choices.year"/>
</component>
</component-specification>
Finally, here's the entire SearchDate.java file, sans comments:
package com.preclick.photowiki.tapestry.component;
import com.preclick.photowiki.search.DateChoices;
import org.apache.tapestry.BaseComponent;
public class SearchDate extends BaseComponent {
protected DateChoices choices;
public DateChoices getChoices() { return choices; }
public void setChoices(DateChoices dc) { choices = dc; }
}
Thank you, Jonny.
Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
"COGITO, EGGO SUM." I think, therefore I am a waffle.
-- .sig of Mr. Ska on Slashdot.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Solved (Was Re: Multiple copies of a component (class for fields))
Posted by Jonny Wray <jo...@yahoo.com>.
Jim,
glad you figured it out. Sorry, I'd assumed you had your own page class
with the two instances of your bean, each bound to the different
instance of your component. One thing. In your page you can reduce java
code and have the framework deal with initialization details by
declaring the class abstract, providing two abstract methods (get and
set choices) and declaring a property-specification eg
<property-specification name="choices"
type="com.preclick.photowiki.search.DateChoices" />
This is probably more important for persistant properties, but works
with non-peristant to reduce the LOC.
As for inherited-binding vs normal, now you have me having to go
back to the docs and figure out the difference. Anyone else care to
explain the difference?
Jonny
--- Jim Menard <ji...@io.com> wrote:
> Solved! Thank you, Jonny.
>
> I needed to make the component-specification a new class, not a
> BaseComponent. The new class does nothing more than hold an instance
> of
> the DateChoices object (the bean with the eight fields).
>
> Then each component needed to use binding normally, not
> inherited-binding, with expressions like "choices.year" and
> "choices.startDate".
>
> Here's the snippet from the page's .page:
>
> <component id="uploadDateChoices" type="SearchDate">
> <binding name="choices" expression="uploadDateChoices"/>
> </component>
>
> <component id="origDateChoices" type="SearchDate">
> <binding name="choices" expression="origDateChoices"/>
> </component>
>
> Here's the part of the component's .jwc:
>
> <component-specification
> class="com.preclick.photowiki.tapestry.component.SearchDate"
> allow-informal-parameters="no">
>
> <parameter name="choices" required="yes" direction="in"
> java-type="com.preclick.photowiki.search.DateChoices"/>
>
> <component id="radioGroup" type="RadioGroup">
> <binding name="selected" expression="choices.which"/>
> </component>
>
> <!-- ... -->
>
> <component id="endDate" type="DatePicker">
> <binding name="value" expression="choices.endDate"/>
> </component>
>
> <component id="monthMenu" type="PropertySelection">
> <binding name="value" expression="choices.monthEnum"/>
> <binding name="model"
>
>
expression="@com.preclick.photowiki.tapestry.page.AdvancedSearchPage@MON
>
> TH_MENU_MODEL"/>
> </component>
>
> <component id="year" type="TextField">
> <binding name="value" expression="choices.year"/>
> </component>
>
> </component-specification>
>
> Finally, here's the entire SearchDate.java file, sans comments:
>
> package com.preclick.photowiki.tapestry.component;
> import com.preclick.photowiki.search.DateChoices;
> import org.apache.tapestry.BaseComponent;
>
> public class SearchDate extends BaseComponent {
>
> protected DateChoices choices;
>
> public DateChoices getChoices() { return choices; }
> public void setChoices(DateChoices dc) { choices = dc; }
>
> }
>
>
> Thank you, Jonny.
>
> Jim
> --
> Jim Menard, jimm@io.com, http://www.io.com/~jimm/
> "COGITO, EGGO SUM." I think, therefore I am a waffle.
> -- .sig of Mr. Ska on Slashdot.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org