Hmm... that's a tricky one... I assumed that RenderInformals always added
informals to the currently rendering element but I can see that this won't
happen if an element has not been added to the MarkupWriter at
beginRender() which happens with the bean edit form. In fact,
RenderInformals won't work as expected on most components which use a
template.

You could write your own mixin to render informal parameters on the last
child of the current element (not tested)

@MixinAfter
@SupportsInformalParameters
public class RenderInformalsOnLastChild {
    @Inject
    private ComponentResources resources;

    void beginRender(MarkupWriter writer)
    {
        List<Node> children = writer.getElement().getChildren();
        Element lastChild = (Element) children.get(children.size() - 1);
        renderInformals(lastChild);
    }

    protected void renderInformals(Element element) {
        for (String name : resources.getInformalParameterNames()) {
           element.attribute(name, resources.getInformalParameter(name,
String.class));
        }
    }
}

On Wednesday, 25 April 2012, Felix Scheffer <fschef...@netzgut.net> wrote:
> Thanks! That was fast :-)
>
> I tried using RenderInformals
>
> <div>
>  <t:beaneditform t:id="entity" ...  t:mixins="RenderInformals"
> class="form-horizontal" >
> </div>
>
> and the result is:
>
> <div class="form-horizontal">
>   <form ...>
>   </form
> </div>
>
> now the class attribute is present, but on the wrong tag (should be on the
> form tag).
> Looks like the form tag has not been rendered when
> RenderInformals.beginRender() method is called.
>
> I would expected that BeanEditForm would call
> "resources.renderInformalParameters(writer);" but it doesnt.  Very
> confusing...
>
> I also tried 5.3.2 and it's exactly the same.
>
> Felix Scheffer
>
>
> 2012/4/25 Chris Mylonas <ch...@opencsta.org>
>
>> was the sarcasm meter on that Lance?
>> :)  - hard to tell at nearly midnight
>>
>> On 25/04/2012, at 11:22 PM, Lance Java wrote:
>>
>> > Try adding the following attribute:
>> > t:mixins="renderInformals"
>> >
>> > If it works, there's a bug ;)
>> >
>> > On Wednesday, 25 April 2012, Felix Scheffer <fschef...@netzgut.net>
>> wrote:
>> >> Hi,
>> >>
>> >> i am using a BeanEditForm and added a class attribute to it, i.e.:
>> >>
>> >> <t:beaneditform t:id="entity"  ...  class="form-horizontal" >
>> >>  ...
>> >> </t:beaneditform>
>> >>
>> >> but the class attribute does not appear in the actual html code:
>> >>
>> >> <form enctype="application/x-www-form-urlencoded"
>> >> onsubmit="javascript:return Tapestry.waitForPage(event);" action="..."
>> >> method="post" id="form">
>> >>
>> >> BeanEditForm has the @SupportsInformalParameters annotation, so am i
>> >> missing something or is this a bug?
>> >>
>> >> Tapestry version is 5.3.3
>> >>
>> >> Thanks a lot!
>> >>
>> >> Felix Scheffer
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>

Reply via email to