You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Artur <a_...@gazeta.pl> on 2013/02/14 14:41:32 UTC

Behavior.renderHead stopped working after migration from 1.4 to 6.5

Hi Guys,

We just migrated our code to W6.5 and are very happy about it.
Unfortunately we don't know how to fix one of the errors.

We did a research but cannot find a solution :(

The code adds a link before a component with some javascript:

             private class ChangeDateBehavior extends Behavior {
   [...]
                 @Override
                 public void renderHead(Component component, 
IHeaderResponse response) {
                     if 
(RequestCycle.get().find(AjaxRequestTarget.class) != null) {
                         String javascript = "var e = Wicket.$('" + 
getMarkupId()
                                 + "'); if (e != null && 
typeof(e.parentNode) != 'undefined') e.parentNode.removeChild(e);";
response.render(JavaScriptHeaderItem.forScript(javascript, null));
                     }
                     String tag = "<a id=\"" + getMarkupId() + 
"\"href=\"#\" onclick=\"changeDate('" + component.getMarkupId()
                         + "', " + Integer.toString(days) + ")\">" + txt 
+ "";
response.render(JavaScriptHeaderItem.forScript(tag, null));

                 }

                 @Override
                 public void bind(Component component) {
                     this.component = component;
                 }

                 public String getMarkupId() {
                     return component.getMarkupId() + "--" + id;
                 }

             }


And the error msg from the console:
ERROR: Wicket.Head.Contributor.processScript: SyntaxError: syntax error: 
eval -> <a id="from2059--lt"href="#" onclick="changeDate('from2059', 
-1)"><<\/a>


Thanks for help in advance,
Artur

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Behavior.renderHead stopped working after migration from 1.4 to 6.5

Posted by Artur <a_...@gazeta.pl>.
Hi,

> try something on the lines...
>
> @Override
> public void afterRender(Component component) {
> component.getResponse().write("your HTML here");
> }
THANK YOU!

It was exactly what I was looking for!
Works great.



Artur


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Behavior.renderHead stopped working after migration from 1.4 to 6.5

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi.

Try something like
Hi,

try something on the lines...

@Override
public void afterRender(Component component) {
component.getResponse().write("your HTML here");
}


On Thu, Feb 14, 2013 at 4:13 PM, Artur <a_...@gazeta.pl> wrote:

> On 2013-02-14 15:13, Ernesto Reinaldo Barreiro wrote:
>
>> Hi,
>>
>> <a id="from2059--lt"href="#" onclick="changeDate('from2059'****,
>> -1)"><<\/a>
>>
>>
>> ins't exactly "proper" JavaScript. What do you want to achieve? Apend that
>> HTML to component's HTML?
>>
> You are of course right.
>
> Yes, I know that is not a valid javascript but it was working somehow in
> previous releases :)
> And I know that wicket execute eval on this. And this is why there is an
> error.
>
> What I want to achieve?
>
> I want to add html link before some wicket component.
> And when clicking on that link I want to call javascript function to
> modify the text value of the component
> without request to the server.
>
> So the question is how to properly add this html snipped to the page.
>
>
> Thanks for help,
>
> Artur
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

Re: Behavior.renderHead stopped working after migration from 1.4 to 6.5

Posted by Artur <a_...@gazeta.pl>.
On 2013-02-14 15:13, Ernesto Reinaldo Barreiro wrote:
> Hi,
>
> <a id="from2059--lt"href="#" onclick="changeDate('from2059'**, -1)"><<\/a>
>
> ins't exactly "proper" JavaScript. What do you want to achieve? Apend that
> HTML to component's HTML?
You are of course right.

Yes, I know that is not a valid javascript but it was working somehow in 
previous releases :)
And I know that wicket execute eval on this. And this is why there is an 
error.

What I want to achieve?

I want to add html link before some wicket component.
And when clicking on that link I want to call javascript function to 
modify the text value of the component
without request to the server.

So the question is how to properly add this html snipped to the page.


Thanks for help,
Artur

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Behavior.renderHead stopped working after migration from 1.4 to 6.5

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,

<a id="from2059--lt"href="#" onclick="changeDate('from2059'**, -1)"><<\/a>

ins't exactly "proper" JavaScript. What do you want to achieve? Apend that
HTML to component's HTML?

On Thu, Feb 14, 2013 at 2:41 PM, Artur <a_...@gazeta.pl> wrote:

> Hi Guys,
>
> We just migrated our code to W6.5 and are very happy about it.
> Unfortunately we don't know how to fix one of the errors.
>
> We did a research but cannot find a solution :(
>
> The code adds a link before a component with some javascript:
>
>             private class ChangeDateBehavior extends Behavior {
>   [...]
>                 @Override
>                 public void renderHead(Component component,
> IHeaderResponse response) {
>                     if (RequestCycle.get().find(**AjaxRequestTarget.class)
> != null) {
>                         String javascript = "var e = Wicket.$('" +
> getMarkupId()
>                                 + "'); if (e != null &&
> typeof(e.parentNode) != 'undefined') e.parentNode.removeChild(e);";
> response.render(**JavaScriptHeaderItem.**forScript(javascript, null));
>                     }
>                     String tag = "<a id=\"" + getMarkupId() +
> "\"href=\"#\" onclick=\"changeDate('" + component.getMarkupId()
>                         + "', " + Integer.toString(days) + ")\">" + txt +
> "";
> response.render(**JavaScriptHeaderItem.**forScript(tag, null));
>
>                 }
>
>                 @Override
>                 public void bind(Component component) {
>                     this.component = component;
>                 }
>
>                 public String getMarkupId() {
>                     return component.getMarkupId() + "--" + id;
>                 }
>
>             }
>
>
> And the error msg from the console:
> ERROR: Wicket.Head.Contributor.**processScript: SyntaxError: syntax
> error: eval -> <a id="from2059--lt"href="#" onclick="changeDate('from2059'
> **, -1)"><<\/a>
>
>
> Thanks for help in advance,
> Artur
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>