[
https://issues.apache.org/jira/browse/TAP5-1918?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jochen Kemnade updated TAP5-1918:
---------------------------------
Description:
The following code:
{code}
<div>
<t:beaneditform t:id="entity" ... t:mixins="RenderInformals" data-foo="bar"
/>
</div>
{code}
Results in the following HTML:
{code}
<div class="form-horizontal" data-foo="bar">
<form ...>
</form
</div>
{code}
As you can see, the informal parameter was added to the div instead of the form.
The current implementation of RenderInformals assumes that a component has
populated the MarkupWriter with an element in beginRender() which is not always
the case. I think it should be changed to use an afterRender() method and add
informals to the current element's last child.
eg:
{code}
@MixinAfter
@SupportsInformalParameters
public class RenderInformals
{
@Inject
private ComponentResources resources;
void afterRender(MarkupWriter writer)
{
List<Node> children = writer.getElement().getChildren();
if (!children.isEmpty()) {
Element lastChild = (Element) children.get(children.size() - 1);
for (String name : resources.getInformalParameterNames()) {
lastChild.attribute(name, resources.getInformalParameter(name,
String.class));
}
}
}
}
{code}
was:
The following code:
<div>
<t:beaneditform t:id="entity" ... t:mixins="RenderInformals"
class="form-horizontal" />
</div>
Results in the following HTML:
<div class="form-horizontal">
<form ...>
</form
</div>
As you can see, the informal parameter was added to the div instead of the form.
The current implementation of RenderInformals assumes that a component has
populated the MarkupWriter with an element in beginRender() which is not always
the case. I think it should be changed to use an afterRender() method and add
informals to the current element's last child.
eg:
@MixinAfter
@SupportsInformalParameters
public class RenderInformals
{
@Inject
private ComponentResources resources;
void afterRender(MarkupWriter writer)
{
List<Node> children = writer.getElement().getChildren();
if (!children.isEmpty()) {
Element lastChild = (Element) children.get(children.size() - 1);
for (String name : resources.getInformalParameterNames()) {
lastChild.attribute(name, resources.getInformalParameter(name,
String.class));
}
}
}
}
> RenderInformals mixin doesn't always work as expected
> -----------------------------------------------------
>
> Key: TAP5-1918
> URL: https://issues.apache.org/jira/browse/TAP5-1918
> Project: Tapestry 5
> Issue Type: Bug
> Affects Versions: 5.3.1, 5.3.2, 5.3.3, 5.4
> Reporter: Lance
> Assignee: Kalle Korhonen
> Priority: Minor
>
> The following code:
> {code}
> <div>
> <t:beaneditform t:id="entity" ... t:mixins="RenderInformals"
> data-foo="bar" />
> </div>
> {code}
> Results in the following HTML:
> {code}
> <div class="form-horizontal" data-foo="bar">
> <form ...>
> </form
> </div>
> {code}
> As you can see, the informal parameter was added to the div instead of the
> form.
> The current implementation of RenderInformals assumes that a component has
> populated the MarkupWriter with an element in beginRender() which is not
> always the case. I think it should be changed to use an afterRender() method
> and add informals to the current element's last child.
> eg:
> {code}
> @MixinAfter
> @SupportsInformalParameters
> public class RenderInformals
> {
> @Inject
> private ComponentResources resources;
>
> void afterRender(MarkupWriter writer)
> {
> List<Node> children = writer.getElement().getChildren();
> if (!children.isEmpty()) {
> Element lastChild = (Element) children.get(children.size() - 1);
> for (String name : resources.getInformalParameterNames()) {
> lastChild.attribute(name, resources.getInformalParameter(name,
> String.class));
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)