You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Jesse Long (JIRA)" <ji...@apache.org> on 2014/03/18 16:48:44 UTC

[jira] [Comment Edited] (WICKET-5531) Create new placeholder tag to indicate where header contributions should appear

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

Jesse Long edited comment on WICKET-5531 at 3/18/14 3:48 PM:
-------------------------------------------------------------

Hi Martin,

Some further testing shows that this is not always working. My original quickstart worked fine, but this new quickstart (wicket-5531-quickstart-2.tar.gz) does not work. Please click on the link on the home page to see the error.

I have tried to debug it, but I'm not sure my solution is correct. Definitely not elegant.

I was able to fix it by overriding getMarkup() in HtmlHeaderItemsContainer as show below. The code is very similar to what happens in HtmlHeaderContainer, but I think HtmlHeaderItemsContainer should probably just look for the first <wicket:header-items> component tag and forget about anything else. Yes? I dont know what ComponentTag.getMarkupClass() is all about so I'm hesitant to start passing judgement on whether or not HtmlHeaderContainer.getMarkup() is correct. Please be so kind as to make this into an elegant solution.

{noformat}
    @Override
    public IMarkupFragment getMarkup()
    {
	if (getParent() == null){
	    throw new WicketRuntimeException(
		    "Bug: The Wicket internal instance of HtmlHeaderContainer is not connected to a parent");
	}

	// Get the page markup
	IMarkupFragment markup = getPage().getMarkup();
	if (markup == null){
	    throw new MarkupException("Unable to get page markup: " + getPage().toString());
	}

	// Find the markup fragment
	MarkupStream stream = new MarkupStream(markup);
	IMarkupFragment headerMarkup = null;
	while (stream.skipUntil(ComponentTag.class) && (headerMarkup == null)){
	    ComponentTag tag = stream.getTag();
	    if (tag.isOpen() || tag.isOpenClose()){
		if (tag instanceof WicketTag){
		    WicketTag wtag = (WicketTag)tag;
#################################################
Look here
#################################################
		    if (wtag.isHeaderItemsTag()){
			headerMarkup = stream.getMarkupFragment();
			break;
		    }
#################################################
/Look here
#################################################
		}
	    }

	    stream.next();
	}

	setMarkup(headerMarkup);
	return headerMarkup;
    }
{noformat}


was (Author: jesselong):
Hi Martin,

Some further testing shows that this is not always working. My original quickstart worked fine, but this new quickstart (wicket-5531-quickstart-2.tar.gz) does not work. Please click on the link on the home page to see the error.

I have tried to debug it, but I'm not sure my solution is correct. Definitely not elegant.

I was able to fix it by overriding getMarkup() in HtmlHeaderItemsContainer as show below. The code is very similar to what happens in HtmlHeaderContainer, but I think HtmlHeaderItemsContainer should probably just look for the first <wicket:header-items> component tag and forget about anything else. Yes? I dont know what ComponentTag.getMarkupClass() is all about so I'm hesitant to start passing judgement on whether or not HtmlHeaderContainer.getMarkup() is correct. Please be so kind as to make this into an elegant solution.


    @Override
    public IMarkupFragment getMarkup()
    {
	if (getParent() == null){
	    throw new WicketRuntimeException(
		    "Bug: The Wicket internal instance of HtmlHeaderContainer is not connected to a parent");
	}

	// Get the page markup
	IMarkupFragment markup = getPage().getMarkup();
	if (markup == null){
	    throw new MarkupException("Unable to get page markup: " + getPage().toString());
	}

	// Find the markup fragment
	MarkupStream stream = new MarkupStream(markup);
	IMarkupFragment headerMarkup = null;
	while (stream.skipUntil(ComponentTag.class) && (headerMarkup == null)){
	    ComponentTag tag = stream.getTag();
	    if (tag.isOpen() || tag.isOpenClose()){
		if (tag instanceof WicketTag){
		    WicketTag wtag = (WicketTag)tag;
#################################################
## Look here
#################################################
		    if (wtag.isHeaderItemsTag()){
			headerMarkup = stream.getMarkupFragment();
			break;
		    }
#################################################
## /Look here
#################################################
		}
	    }

	    stream.next();
	}

	setMarkup(headerMarkup);
	return headerMarkup;
    }


> Create new placeholder tag to indicate where header contributions should appear
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-5531
>                 URL: https://issues.apache.org/jira/browse/WICKET-5531
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.14.0
>            Reporter: Jesse Long
>            Assignee: Martin Grigorov
>            Priority: Minor
>             Fix For: 7.0.0, 6.15.0
>
>         Attachments: wicket-5531-quickstart-2.tar.gz, wicket-5531.tar.gz
>
>
> It would be easier to manage exactly where header contributions are positioned in the head of the document if there was a placeholder tag which could be used to indicate the position. Much in the same way as wicket:child indicates where the child markup is positioned.
> This idea from Martin-G.
> See discussion at http://mail-archives.apache.org/mod_mbox/wicket-dev/201304.mbox/%3CCAMomwMqRds-PhWkR_%3DR1x-4HH9sSW41H1nARacU%2BN15uJHh9SA%40mail.gmail.com%3E



--
This message was sent by Atlassian JIRA
(v6.2#6252)