You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Juergen Donnerstag (JIRA)" <ji...@apache.org> on 2010/05/25 18:08:27 UTC

[jira] Commented: (WICKET-2874) Copy attributes from wicket:panel to source tag

    [ https://issues.apache.org/jira/browse/WICKET-2874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12871221#action_12871221 ] 

Juergen Donnerstag commented on WICKET-2874:
--------------------------------------------

Though possible, it requires modifications to the API which are not possible in 1.4. 
Reason: onComponentTag() currently doesn't need the associated markup, thus it is loaded during onComponentTagBody. We'd need to change the code to read the associated markup in onComponentTag(), store is locally and re-use it during onComponentTagBody() to be efficient. 

But I think I have a workaround for you: src/test/.../PanelWithAttributeModifier.java shows that you can add an AttributeModifier to the Panel within the Panel's constructor - which makes it Panel specific -, which during rendering modifies the Panel opening <div> tag.

You could further refine that if you'd put the following snippet in your Panel construtor, which loads the associated markup and does some sanity tests. The result is the <wicket:panel> ComponentTag. The ComponentTag in turn provides you the attributes which your AM would add to the <div> tag.

Obviously these Panels would read the Markup twice, which is not very desireable. It's probably not a big performance impact because of caching, but ...

		final MarkupStream associatedMarkupStream = getAssociatedMarkupStream(true);

		// skip until the targetted tag is found
		associatedMarkupStream.skipUntil(openTagName);

		// Get open tag in associated markup of border component
		MarkupElement elem = associatedMarkupStream.get();
		if ((elem instanceof ComponentTag) == false)
		{
			associatedMarkupStream.throwMarkupException("Expected the open tag. " +
				exceptionMessage);
		}

		ComponentTag associatedMarkupOpenTag = (ComponentTag)elem;

		// Check for required open tag name
		if (!((associatedMarkupOpenTag != null) && associatedMarkupOpenTag.isOpen() && (associatedMarkupOpenTag instanceof WicketTag)))
		{
			associatedMarkupStream.throwMarkupException(exceptionMessage);
		}



> Copy attributes from wicket:panel to source tag
> -----------------------------------------------
>
>                 Key: WICKET-2874
>                 URL: https://issues.apache.org/jira/browse/WICKET-2874
>             Project: Wicket
>          Issue Type: New Feature
>          Components: wicket
>    Affects Versions: 1.4.7
>            Reporter: Maarten Billemont
>
> When I have a page like so:
> {code}
> <div wicket:id="content" />
> {code}
> And two types of panels that could go in there, that should have different styling, I'm currently stuck using a pointless extra div:
> {code}
> <wicket:panel>
>     <div class="style1">
>         Content 1
>     </div>
> </wicket:panel>
> {code}
> If wicket allows copying attributes on from the wicket:panel tag to the source tag of the panel; this would become a lot cleaner and neater:
> {code}
> <wicket:panel class="style1">
>     Content 1
> </wicket:panel>
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.