You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by llama-king <p....@albourne.com> on 2013/02/12 13:54:18 UTC

Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

Posted by llama-king <p....@albourne.com>.
Just had a moment to put together the rest of my accordion component with two
components. It's definitely more elegant than all the slinging of parameters
and coercing blocks out of informal parameter titles and of course it
affords you looping.

I'd have to agree that the t5-jquery tabs could be re-imagined via the same
approach.



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

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


Re: Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

Posted by Lance Java <la...@googlemail.com>.
Yes!!

IMHO I think the tapestry-jquery tabs component uses the "messy" parameters
I was referring to
http://tapestry5-jquery.com/components/docsjquerytabs



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

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


Re: Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

Posted by Emmanuel DEMEY <de...@gmail.com>.
Hi

Something like our Carousel component :
https://github.com/got5/tapestry5-jquery/blob/master/src/test/resources/org/got5/tapestry5/jquery/pages/CarouselPage.tml?

Manu


2013/2/12 Lance Java <la...@googlemail.com>

> I much prefer to use components for this sort of thing. If you use
> parameters, you start to do all kinds of messy stuff with naming
> conventions:
>
> eg:
> <t:accordion order="item1,item2" item1Title="Item 1" item2Title="Item 2">
>    <p:item1Body>Body 1</p:entry1Body>
>    <p:item2Body>Body 1</p:entry2Body>
> </t:accordion>
>
> I think 2 components is much cleaner and has the benefit IDE tooling
> support.
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Component-Utilizing-PropertyOverrides-Adding-Override-Blocks-Dynamically-tp5719973p5719980.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Emmanuel DEMEY
Ingénieur Etude et Développement
ATOS Worldline
+33 (0)6 47 47 42 02
demey.emmanuel@gmail.com
http://emmanueldemey.fr/

Twitter : @EmmanuelDemey

Re: Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

Posted by Lance Java <la...@googlemail.com>.
I much prefer to use components for this sort of thing. If you use
parameters, you start to do all kinds of messy stuff with naming
conventions:

eg:
<t:accordion order="item1,item2" item1Title="Item 1" item2Title="Item 2">
   <p:item1Body>Body 1</p:entry1Body>
   <p:item2Body>Body 1</p:entry2Body>
</t:accordion>

I think 2 components is much cleaner and has the benefit IDE tooling
support.




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

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


Re: Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

Posted by llama-king <p....@albourne.com>.
Hi Lance,

That really is looking like the only plausible solution that hides away
boilerplate mark-up/config. All these kinds of components are very similar
in nature. (Bung some things into other named things under a thing). It
would be cool to be able to mangle (read: modify) the parameter tag to allow
this sort of flexibility and avoid creating another component but perhaps
the difference is just 'icing', a couple of files here or there.

Thanks for the response. I guess I'll go in this direction unless a blinding
strike of lightning (or someone else) hits me in the face later on! :)



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

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


Re: Component Utilizing PropertyOverrides, Adding Override Blocks Dynamically

Posted by Lance Java <la...@googlemail.com>.
Why not use two separate components.

<t:accordion>
   <t:accordionItem title="Item 1">Item 1 Body</t:accordionItem>
   <t:accordionItem title="Item 2">Item 2 Body</t:accordionItem>
</t:accordion>

I do a similar thing with TabGroup/Tab here

Demo: 
https://github.com/uklance/tapestry-stitch-demo/blob/master/src/main/resources/org/lazan/t5/stitch/demo/pages/TabGroupDemo.tml
https://github.com/uklance/tapestry-stitch-demo/blob/master/src/main/java/org/lazan/t5/stitch/demo/pages/TabGroupDemo.java

Source: 
https://github.com/uklance/tapestry-stitch/blob/master/src/main/java/org/lazan/t5/stitch/components/TabGroup.java
https://github.com/uklance/tapestry-stitch/blob/master/src/main/resources/org/lazan/t5/stitch/components/TabGroup.tml
https://github.com/uklance/tapestry-stitch/blob/master/src/main/java/org/lazan/t5/stitch/components/Tab.java
https://github.com/uklance/tapestry-stitch/blob/master/src/main/java/org/lazan/t5/stitch/model/TabModel.java



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

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