This component will grab the first element from the template and add
all the informal parameters to it.

@SupportsInformalParameters
public class Inf {

    @Inject
    private ComponentResources _resources;

    void afterRenderTemplate(MarkupWriter writer) {
        Element wrapper = null;
        // find first element added by the template (could be comment etc...)
        for (Node child : writer.getElement().getChildren()) {
            if (child instanceof Element) {
                wrapper = (Element) child;
                break;
            }
        }

        if (wrapper != null) {
            final List<String> names = _resources.getInformalParameterNames();
            for (String name : names) {
                wrapper.attribute(name,
_resources.getInformalParameter(name, String.class));
            }
        }
    }
}

Josh


On Fri, Sep 18, 2009 at 9:12 AM, Kai Weber <kai.we...@glorybox.de> wrote:
> Hi,
>
> I have *exactly* the same problem as the user adamh in June 2008. He hasn't 
> got an answer. Does, one year later, anyone has a glue?
>
> http://www.nabble.com/RenderInformals-on-Component-With-Template-tt18053261.html#a18053261
>
> In short this is his problem:
>
> Inf.tml
> <div existing="existing" 
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
>        Inf Component
> </div>
>
> InfTest.tml
> <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
>
> <!-- This inf component should render with 'existing' and 'inf1' attributes 
> -->
> <t:inf inf1="inf1">Hi</t:inf>
>
> </div>
>
> Regards, Kai
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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

Reply via email to