Hello,

I started writing an Accordion component today to try out using the
following sort of pattern;

<t:accordion>
    <p:itemFirst>Some content..</p:itemFirst>
    <p:itemAnother>Some more content..</p:itemAnother>
</t:accordion>

So I specify PropertyOverrides in Accordion.java:
        @Parameter(value = "this", allowNull = false)
        @Property(write = false)
        private PropertyOverrides overrides_;

In order to pick up on the names of the overrides I loop through
ComponentResources.getInformalParameterNames() and pick up anything prefixed
with 'item'.

I then loop over these names in the tml and use the delegate component which
gets its block from PropertyOverrides.getOverrideBlock(itemname).

This works nicely - whether or not it would be better to explicitly,
manually pass in the list of override block names as a parameter to the
component is another question; I'd be interested to hear people's thoughts
regardless.

Now, I'm most interested in a scenario where I want to add very similar
items to my accordion via a loop. The number of items to be added is unknown
to me, depends on user input. So I'm looking for something that would
conceptually boil down to the following in a tml:

<t:accordion>
    <t:loop source="itemnames" value="itemname">
        <p:item (with name, itemname)>
            <t:somecomponentthatvariesslightlyasweloop params="params" />
        </p:item (with name, itemname)>
    </t:loop>
</t:accordion>

Of course I could just resort to using my Accordion's front-end CSS classes,
that way I could just loop through and p:item would become some indented,
repeated, boilerplate divs with class accordion-item, accordion-item-title,
accordion-item-content... but it would be way nicer to do this in as above.

Thanks again!





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Component-Utilizing-PropertyOverrides-Adding-Override-Blocks-Dynamically-tp5719973.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to