You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Lance (JIRA)" <ji...@apache.org> on 2012/04/26 10:56:12 UTC
[jira] [Created] (TAP5-1918) RenderInformals mixin doesn't always
work as expected
Lance created TAP5-1918:
---------------------------
Summary: 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.3, 5.3.2, 5.3.1
Reporter: Lance
Priority: Minor
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));
}
}
}
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (TAP5-1918) RenderInformals mixin doesn't always
work as expected
Posted by "Peter H (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1918?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470291#comment-13470291 ]
Peter H commented on TAP5-1918:
-------------------------------
This is slightly harder to observe when the component we're expecting informals on is rendered as part of a partial response. Instead the root tag (parent element) of the partial render (which is never actually displayed in the browser) takes the informal parameters making this a real head scratcher to figure out without printing the writer and seeing this.
We are using Lance's suggested implementation until this bug gets resolved. Many thanks!
> 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
> Reporter: Lance
> Priority: Minor
>
> 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));
> }
> }
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (TAP5-1918) RenderInformals mixin doesn't always
work as expected
Posted by "Peter H (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1918?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470291#comment-13470291 ]
Peter H commented on TAP5-1918:
-------------------------------
This is slightly harder to observe when the component we're expecting informals on is rendered as part of a partial response. Instead the root tag (parent element) of the partial render (which is never actually displayed in the browser) takes the informal parameters making this a real head scratcher to figure out without printing the writer and seeing this.
We are using Lance's suggested implementation until this bug gets resolved. Many thanks!
> 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
> Reporter: Lance
> Priority: Minor
>
> 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));
> }
> }
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira