You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by eyalbenamram <ey...@gmail.com> on 2008/10/28 18:57:54 UTC
inserting javascript from java to html file
Hi
I am inserting javascript code like this:
StringBuffer config = new StringBuffer();
config.append("<script language=\"JavaScript\">\n");
config.append("function onLoad() { getValue();
setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
config.append("function onRefresh(){\n");
config.append("document.getElementById('hiddenVar').value =
document.getElementById('textString').value;\n");
config.append("window.location.reload(); }\n");
config.append("function getValue() {\n");
config.append("document.getElementById('textString').value =
document.getElementById('hiddenVar').value; }\n");
config.append("</script>\n");
/*open to activate JS*/
add(new StringHeaderContributor(config.toString()));
and receive an error in log file:
http-6789-2 ERROR html.WebPage -
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
<header> tag to your markup since no Header Container was
found but components where found which want to write to the <head> section.
<script language="JavaScript">
function removeBlur(checked) {
if(checked) {
document.getElementById('login_button').disabled = false;
} else {
document.getElementById('login_button').disabled = true;
} }
</script>
although my html file contains a <head> tag, and the javascript code
actually appears in the rendered page (when I look at the source of the
page).
any idea?
Thanks,Eyal.
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by eyalbenamram <ey...@gmail.com>.
but StringHeaderContibutor implement IHeaderContributor...
I also verfied <body> tag exists...
Can you please give a code ample. it will be much easier..
Thanks.
igor.vaynberg wrote:
>
> use iheadercontributor, that should work much better
>
> also make sure your page has <body> tag.
>
> -igor
>
> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com>
> wrote:
>>
>> Hi
>> I am inserting javascript code like this:
>>
>> StringBuffer config = new StringBuffer();
>>
>> config.append("<script language=\"JavaScript\">\n");
>> config.append("function onLoad() { getValue();
>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>> config.append("function onRefresh(){\n");
>> config.append("document.getElementById('hiddenVar').value
>> =
>> document.getElementById('textString').value;\n");
>> config.append("window.location.reload(); }\n");
>> config.append("function getValue() {\n");
>> config.append("document.getElementById('textString').value
>> =
>> document.getElementById('hiddenVar').value; }\n");
>> config.append("</script>\n");
>>
>> /*open to activate JS*/
>> add(new StringHeaderContributor(config.toString()));
>>
>>
>> and receive an error in log file:
>>
>> http-6789-2 ERROR html.WebPage -
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
>> <header> tag to your markup since no Header Container was
>> found but components where found which want to write to the <head>
>> section.
>> <script language="JavaScript">
>> function removeBlur(checked) {
>> if(checked) {
>> document.getElementById('login_button').disabled = false;
>> } else {
>> document.getElementById('login_button').disabled = true;
>> } }
>> </script>
>>
>> although my html file contains a <head> tag, and the javascript code
>> actually appears in the rendered page (when I look at the source of the
>> page).
>>
>> any idea?
>>
>> Thanks,Eyal.
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213031.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by eyalbenamram <ey...@gmail.com>.
Sorry, I understood what you meant and used IHeaderContributor. Thanks.
igor.vaynberg wrote:
>
> use iheadercontributor, that should work much better
>
> also make sure your page has <body> tag.
>
> -igor
>
> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com>
> wrote:
>>
>> Hi
>> I am inserting javascript code like this:
>>
>> StringBuffer config = new StringBuffer();
>>
>> config.append("<script language=\"JavaScript\">\n");
>> config.append("function onLoad() { getValue();
>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>> config.append("function onRefresh(){\n");
>> config.append("document.getElementById('hiddenVar').value
>> =
>> document.getElementById('textString').value;\n");
>> config.append("window.location.reload(); }\n");
>> config.append("function getValue() {\n");
>> config.append("document.getElementById('textString').value
>> =
>> document.getElementById('hiddenVar').value; }\n");
>> config.append("</script>\n");
>>
>> /*open to activate JS*/
>> add(new StringHeaderContributor(config.toString()));
>>
>>
>> and receive an error in log file:
>>
>> http-6789-2 ERROR html.WebPage -
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
>> <header> tag to your markup since no Header Container was
>> found but components where found which want to write to the <head>
>> section.
>> <script language="JavaScript">
>> function removeBlur(checked) {
>> if(checked) {
>> document.getElementById('login_button').disabled = false;
>> } else {
>> document.getElementById('login_button').disabled = true;
>> } }
>> </script>
>>
>> although my html file contains a <head> tag, and the javascript code
>> actually appears in the rendered page (when I look at the source of the
>> page).
>>
>> any idea?
>>
>> Thanks,Eyal.
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213139.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by Igor Vaynberg <ig...@gmail.com>.
what you pasted looks ok, but its incomplete. go ahead and create a
quickstart and a jira issue and i will take a look.
-igor
On Wed, Oct 29, 2008 at 2:07 AM, eyalbenamram <ey...@gmail.com> wrote:
>
> OK. I used the IHeader contributor and the problem still exist!
>
> The error:
>
> http-6789-2 ERROR html.WebPage -
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
> <header> tag to your markup since no Header Container was
> found but components where found which want to write to the <head> section.
> <script type="text/javascript"
> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
> Wicket.Event.add(window, "load", function() { function removeBlur(checked) {
> if(checked) {
> document.getElementById('login_button').disabled = false;
> } else {
> document.getElementById('login_button').disabled = true;
> } }
> ;});
> /*-->]]>*/</script>
>
>
> http-6789-2 ERROR html.WebPage -
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> The html:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
> "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
> xmlns:wicket="http://wicket.apache.org/" wicket:id="htmlTag" dir="ltr">
> <head>
>
> <title wicket:id="title">title</title>
>
> <style type="text/css">
> body {background-color: #FFFFFF; font-family:verdana;}
> a {margin:0px 3px 0px 3px;}
> .link{ font-weight: bold;
> white-space: nowrap;
> margin-left: 5px;
> }
> .center{ text-align: center;}
> .header {background:#FFFFFF;
> border-bottom: rgb(51,102,204) solid 3px;
> width:100%;
> line-height: 150%;
> text-align: center;
> }
> .footer{background:rgb(204,236,255);
> border-top: blue solid 3px;
> text-align: center;
> /* position:fixed; */
> /* bottom:0px; */
> width:100%;
> line-height: 125%;
> }
> .form {
> line-height: 150%;
> margin-bottom: 5px;
> }
> #submitButton {
> width: 100px;
> }
> </style>
> </head>
>
> <body wicket:id="body" onload="JavaScript:removeBlur(false);">
>
> The java:
>
> public void renderHead(IHeaderResponse response) {
>
> StringBuffer config = new StringBuffer();
>
>
> config.append("function removeBlur(checked) {\n");
> config.append("if(checked) {\n");
> config.append("document.getElementById('login_button').disabled =
> false;\n");
> config.append("} else {\n");
> config.append("document.getElementById('login_button').disabled =
> true;\n");
> config.append("} }\n");
>
> response.renderOnLoadJavascript(config.toString());
> }
>
> What am I doing wrong???
>
>
>
> igor.vaynberg wrote:
>>
>> huh? it did not create the file....your javascript will be inlined!
>>
>> you are using the onloadjavascript which needs support for the onload
>> event, which is why the wicket-event.js is included before your
>> javascript.
>>
>> all this is apparent just by looking at the output code, you can see
>> your code being inlined...
>>
>> -igor
>>
>> On Tue, Oct 28, 2008 at 11:45 AM, eyalbenamram <ey...@gmail.com>
>> wrote:
>>>
>>> OK. What if I want all the JS to be inline (no .js file to be made)?
>>> I saw that wicket created a .js file...
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> response.renderOnLoadJavascript() takes just the javascript - like the
>>>> javadoc says. no need for you to output the script tags.
>>>>
>>>> -igor
>>>>
>>>> On Tue, Oct 28, 2008 at 11:33 AM, eyalbenamram <ey...@gmail.com>
>>>> wrote:
>>>>>
>>>>> public void renderHead(IHeaderResponse response) {
>>>>>
>>>>>
>>>>> StringBuffer config = new StringBuffer();
>>>>>
>>>>> config.append("<script language=\"JavaScript\">\n");
>>>>> config.append("function removeBlur(checked) {\n");
>>>>> config.append("if(checked) {\n");
>>>>>
>>>>> config.append("document.getElementById('login_button').disabled =
>>>>> false;\n");
>>>>> config.append("} else {\n");
>>>>>
>>>>> config.append("document.getElementById('login_button').disabled =
>>>>> true;\n");
>>>>> config.append("} }\n");
>>>>> config.append("</script>\n");
>>>>>
>>>>> response.renderOnLoadJavascript(config.toString());
>>>>>
>>>>>
>>>>>
>>>>> igor.vaynberg wrote:
>>>>>>
>>>>>> what is your code look like?
>>>>>>
>>>>>> -igor
>>>>>>
>>>>>> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram
>>>>>> <ey...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi again,
>>>>>>>
>>>>>>> I used IHeaderContributer, and the javascript code is now garbled and
>>>>>>> not
>>>>>>> working.
>>>>>>> Here is what I got:
>>>>>>>
>>>>>>> <script type="text/javascript"
>>>>>>> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
>>>>>>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>>>>>>> Wicket.Event.add(window, "load", function() { <script
>>>>>>> language="JavaScript">
>>>>>>> function removeBlur(checked) {
>>>>>>> if(checked) {
>>>>>>> document.getElementById('login_button').disabled = false;
>>>>>>> } else {
>>>>>>> document.getElementById('login_button').disabled = true;
>>>>>>> } }
>>>>>>> </script>
>>>>>>> ;});
>>>>>>> /*-->]]>*/</script>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> igor.vaynberg wrote:
>>>>>>>>
>>>>>>>> use iheadercontributor, that should work much better
>>>>>>>>
>>>>>>>> also make sure your page has <body> tag.
>>>>>>>>
>>>>>>>> -igor
>>>>>>>>
>>>>>>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram
>>>>>>>> <ey...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>> I am inserting javascript code like this:
>>>>>>>>>
>>>>>>>>> StringBuffer config = new StringBuffer();
>>>>>>>>>
>>>>>>>>> config.append("<script language=\"JavaScript\">\n");
>>>>>>>>> config.append("function onLoad() { getValue();
>>>>>>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+");
>>>>>>>>> }\n");
>>>>>>>>> config.append("function onRefresh(){\n");
>>>>>>>>>
>>>>>>>>> config.append("document.getElementById('hiddenVar').value
>>>>>>>>> =
>>>>>>>>> document.getElementById('textString').value;\n");
>>>>>>>>> config.append("window.location.reload(); }\n");
>>>>>>>>> config.append("function getValue() {\n");
>>>>>>>>>
>>>>>>>>> config.append("document.getElementById('textString').value
>>>>>>>>> =
>>>>>>>>> document.getElementById('hiddenVar').value; }\n");
>>>>>>>>> config.append("</script>\n");
>>>>>>>>>
>>>>>>>>> /*open to activate JS*/
>>>>>>>>> add(new StringHeaderContributor(config.toString()));
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> and receive an error in log file:
>>>>>>>>>
>>>>>>>>> http-6789-2 ERROR html.WebPage -
>>>>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a
>>>>>>>>> <body>
>>>>>>>>> or
>>>>>>>>> <header> tag to your markup since no Header Container was
>>>>>>>>> found but components where found which want to write to the <head>
>>>>>>>>> section.
>>>>>>>>> <script language="JavaScript">
>>>>>>>>> function removeBlur(checked) {
>>>>>>>>> if(checked) {
>>>>>>>>> document.getElementById('login_button').disabled = false;
>>>>>>>>> } else {
>>>>>>>>> document.getElementById('login_button').disabled = true;
>>>>>>>>> } }
>>>>>>>>> </script>
>>>>>>>>>
>>>>>>>>> although my html file contains a <head> tag, and the javascript
>>>>>>>>> code
>>>>>>>>> actually appears in the rendered page (when I look at the source of
>>>>>>>>> the
>>>>>>>>> page).
>>>>>>>>>
>>>>>>>>> any idea?
>>>>>>>>>
>>>>>>>>> Thanks,Eyal.
>>>>>>>>> --
>>>>>>>>> View this message in context:
>>>>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>>>>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
>>>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213326.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213513.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20223155.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by eyalbenamram <ey...@gmail.com>.
OK. I used the IHeader contributor and the problem still exist!
The error:
http-6789-2 ERROR html.WebPage -
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
<header> tag to your markup since no Header Container was
found but components where found which want to write to the <head> section.
<script type="text/javascript"
src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
<script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
Wicket.Event.add(window, "load", function() { function removeBlur(checked) {
if(checked) {
document.getElementById('login_button').disabled = false;
} else {
document.getElementById('login_button').disabled = true;
} }
;});
/*-->]]>*/</script>
http-6789-2 ERROR html.WebPage -
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The html:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:wicket="http://wicket.apache.org/" wicket:id="htmlTag" dir="ltr">
<head>
<title wicket:id="title">title</title>
<style type="text/css">
body {background-color: #FFFFFF; font-family:verdana;}
a {margin:0px 3px 0px 3px;}
.link{ font-weight: bold;
white-space: nowrap;
margin-left: 5px;
}
.center{ text-align: center;}
.header {background:#FFFFFF;
border-bottom: rgb(51,102,204) solid 3px;
width:100%;
line-height: 150%;
text-align: center;
}
.footer{background:rgb(204,236,255);
border-top: blue solid 3px;
text-align: center;
/* position:fixed; */
/* bottom:0px; */
width:100%;
line-height: 125%;
}
.form {
line-height: 150%;
margin-bottom: 5px;
}
#submitButton {
width: 100px;
}
</style>
</head>
<body wicket:id="body" onload="JavaScript:removeBlur(false);">
The java:
public void renderHead(IHeaderResponse response) {
StringBuffer config = new StringBuffer();
config.append("function removeBlur(checked) {\n");
config.append("if(checked) {\n");
config.append("document.getElementById('login_button').disabled =
false;\n");
config.append("} else {\n");
config.append("document.getElementById('login_button').disabled =
true;\n");
config.append("} }\n");
response.renderOnLoadJavascript(config.toString());
}
What am I doing wrong???
igor.vaynberg wrote:
>
> huh? it did not create the file....your javascript will be inlined!
>
> you are using the onloadjavascript which needs support for the onload
> event, which is why the wicket-event.js is included before your
> javascript.
>
> all this is apparent just by looking at the output code, you can see
> your code being inlined...
>
> -igor
>
> On Tue, Oct 28, 2008 at 11:45 AM, eyalbenamram <ey...@gmail.com>
> wrote:
>>
>> OK. What if I want all the JS to be inline (no .js file to be made)?
>> I saw that wicket created a .js file...
>>
>>
>> igor.vaynberg wrote:
>>>
>>> response.renderOnLoadJavascript() takes just the javascript - like the
>>> javadoc says. no need for you to output the script tags.
>>>
>>> -igor
>>>
>>> On Tue, Oct 28, 2008 at 11:33 AM, eyalbenamram <ey...@gmail.com>
>>> wrote:
>>>>
>>>> public void renderHead(IHeaderResponse response) {
>>>>
>>>>
>>>> StringBuffer config = new StringBuffer();
>>>>
>>>> config.append("<script language=\"JavaScript\">\n");
>>>> config.append("function removeBlur(checked) {\n");
>>>> config.append("if(checked) {\n");
>>>>
>>>> config.append("document.getElementById('login_button').disabled =
>>>> false;\n");
>>>> config.append("} else {\n");
>>>>
>>>> config.append("document.getElementById('login_button').disabled =
>>>> true;\n");
>>>> config.append("} }\n");
>>>> config.append("</script>\n");
>>>>
>>>> response.renderOnLoadJavascript(config.toString());
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> what is your code look like?
>>>>>
>>>>> -igor
>>>>>
>>>>> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram
>>>>> <ey...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi again,
>>>>>>
>>>>>> I used IHeaderContributer, and the javascript code is now garbled and
>>>>>> not
>>>>>> working.
>>>>>> Here is what I got:
>>>>>>
>>>>>> <script type="text/javascript"
>>>>>> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
>>>>>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>>>>>> Wicket.Event.add(window, "load", function() { <script
>>>>>> language="JavaScript">
>>>>>> function removeBlur(checked) {
>>>>>> if(checked) {
>>>>>> document.getElementById('login_button').disabled = false;
>>>>>> } else {
>>>>>> document.getElementById('login_button').disabled = true;
>>>>>> } }
>>>>>> </script>
>>>>>> ;});
>>>>>> /*-->]]>*/</script>
>>>>>>
>>>>>>
>>>>>>
>>>>>> igor.vaynberg wrote:
>>>>>>>
>>>>>>> use iheadercontributor, that should work much better
>>>>>>>
>>>>>>> also make sure your page has <body> tag.
>>>>>>>
>>>>>>> -igor
>>>>>>>
>>>>>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram
>>>>>>> <ey...@gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>> I am inserting javascript code like this:
>>>>>>>>
>>>>>>>> StringBuffer config = new StringBuffer();
>>>>>>>>
>>>>>>>> config.append("<script language=\"JavaScript\">\n");
>>>>>>>> config.append("function onLoad() { getValue();
>>>>>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+");
>>>>>>>> }\n");
>>>>>>>> config.append("function onRefresh(){\n");
>>>>>>>>
>>>>>>>> config.append("document.getElementById('hiddenVar').value
>>>>>>>> =
>>>>>>>> document.getElementById('textString').value;\n");
>>>>>>>> config.append("window.location.reload(); }\n");
>>>>>>>> config.append("function getValue() {\n");
>>>>>>>>
>>>>>>>> config.append("document.getElementById('textString').value
>>>>>>>> =
>>>>>>>> document.getElementById('hiddenVar').value; }\n");
>>>>>>>> config.append("</script>\n");
>>>>>>>>
>>>>>>>> /*open to activate JS*/
>>>>>>>> add(new StringHeaderContributor(config.toString()));
>>>>>>>>
>>>>>>>>
>>>>>>>> and receive an error in log file:
>>>>>>>>
>>>>>>>> http-6789-2 ERROR html.WebPage -
>>>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a
>>>>>>>> <body>
>>>>>>>> or
>>>>>>>> <header> tag to your markup since no Header Container was
>>>>>>>> found but components where found which want to write to the <head>
>>>>>>>> section.
>>>>>>>> <script language="JavaScript">
>>>>>>>> function removeBlur(checked) {
>>>>>>>> if(checked) {
>>>>>>>> document.getElementById('login_button').disabled = false;
>>>>>>>> } else {
>>>>>>>> document.getElementById('login_button').disabled = true;
>>>>>>>> } }
>>>>>>>> </script>
>>>>>>>>
>>>>>>>> although my html file contains a <head> tag, and the javascript
>>>>>>>> code
>>>>>>>> actually appears in the rendered page (when I look at the source of
>>>>>>>> the
>>>>>>>> page).
>>>>>>>>
>>>>>>>> any idea?
>>>>>>>>
>>>>>>>> Thanks,Eyal.
>>>>>>>> --
>>>>>>>> View this message in context:
>>>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>>>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
>>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213326.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213513.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20223155.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by Igor Vaynberg <ig...@gmail.com>.
huh? it did not create the file....your javascript will be inlined!
you are using the onloadjavascript which needs support for the onload
event, which is why the wicket-event.js is included before your
javascript.
all this is apparent just by looking at the output code, you can see
your code being inlined...
-igor
On Tue, Oct 28, 2008 at 11:45 AM, eyalbenamram <ey...@gmail.com> wrote:
>
> OK. What if I want all the JS to be inline (no .js file to be made)?
> I saw that wicket created a .js file...
>
>
> igor.vaynberg wrote:
>>
>> response.renderOnLoadJavascript() takes just the javascript - like the
>> javadoc says. no need for you to output the script tags.
>>
>> -igor
>>
>> On Tue, Oct 28, 2008 at 11:33 AM, eyalbenamram <ey...@gmail.com>
>> wrote:
>>>
>>> public void renderHead(IHeaderResponse response) {
>>>
>>>
>>> StringBuffer config = new StringBuffer();
>>>
>>> config.append("<script language=\"JavaScript\">\n");
>>> config.append("function removeBlur(checked) {\n");
>>> config.append("if(checked) {\n");
>>>
>>> config.append("document.getElementById('login_button').disabled =
>>> false;\n");
>>> config.append("} else {\n");
>>>
>>> config.append("document.getElementById('login_button').disabled =
>>> true;\n");
>>> config.append("} }\n");
>>> config.append("</script>\n");
>>>
>>> response.renderOnLoadJavascript(config.toString());
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> what is your code look like?
>>>>
>>>> -igor
>>>>
>>>> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram <ey...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi again,
>>>>>
>>>>> I used IHeaderContributer, and the javascript code is now garbled and
>>>>> not
>>>>> working.
>>>>> Here is what I got:
>>>>>
>>>>> <script type="text/javascript"
>>>>> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
>>>>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>>>>> Wicket.Event.add(window, "load", function() { <script
>>>>> language="JavaScript">
>>>>> function removeBlur(checked) {
>>>>> if(checked) {
>>>>> document.getElementById('login_button').disabled = false;
>>>>> } else {
>>>>> document.getElementById('login_button').disabled = true;
>>>>> } }
>>>>> </script>
>>>>> ;});
>>>>> /*-->]]>*/</script>
>>>>>
>>>>>
>>>>>
>>>>> igor.vaynberg wrote:
>>>>>>
>>>>>> use iheadercontributor, that should work much better
>>>>>>
>>>>>> also make sure your page has <body> tag.
>>>>>>
>>>>>> -igor
>>>>>>
>>>>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram
>>>>>> <ey...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi
>>>>>>> I am inserting javascript code like this:
>>>>>>>
>>>>>>> StringBuffer config = new StringBuffer();
>>>>>>>
>>>>>>> config.append("<script language=\"JavaScript\">\n");
>>>>>>> config.append("function onLoad() { getValue();
>>>>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>>>>>>> config.append("function onRefresh(){\n");
>>>>>>>
>>>>>>> config.append("document.getElementById('hiddenVar').value
>>>>>>> =
>>>>>>> document.getElementById('textString').value;\n");
>>>>>>> config.append("window.location.reload(); }\n");
>>>>>>> config.append("function getValue() {\n");
>>>>>>>
>>>>>>> config.append("document.getElementById('textString').value
>>>>>>> =
>>>>>>> document.getElementById('hiddenVar').value; }\n");
>>>>>>> config.append("</script>\n");
>>>>>>>
>>>>>>> /*open to activate JS*/
>>>>>>> add(new StringHeaderContributor(config.toString()));
>>>>>>>
>>>>>>>
>>>>>>> and receive an error in log file:
>>>>>>>
>>>>>>> http-6789-2 ERROR html.WebPage -
>>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body>
>>>>>>> or
>>>>>>> <header> tag to your markup since no Header Container was
>>>>>>> found but components where found which want to write to the <head>
>>>>>>> section.
>>>>>>> <script language="JavaScript">
>>>>>>> function removeBlur(checked) {
>>>>>>> if(checked) {
>>>>>>> document.getElementById('login_button').disabled = false;
>>>>>>> } else {
>>>>>>> document.getElementById('login_button').disabled = true;
>>>>>>> } }
>>>>>>> </script>
>>>>>>>
>>>>>>> although my html file contains a <head> tag, and the javascript code
>>>>>>> actually appears in the rendered page (when I look at the source of
>>>>>>> the
>>>>>>> page).
>>>>>>>
>>>>>>> any idea?
>>>>>>>
>>>>>>> Thanks,Eyal.
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213326.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213513.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: inserting javascript from java to html file
Posted by "Hoover, William " <wh...@nemours.org>.
or you can use:
https://svn.apache.org/repos/asf/wicket/trunk/wicket-velocity/ in which
case you could have a separate js/vm file that can inject the values for
you:
myscript.vm
<script language="JavaScript">
function removeBlur(checked) {
if(checked) {
document.getElementById('${loginButtonId}').disabled = false;
} else {
document.getElementById('${loginButtonId}').disabled = true;
}
}
</script>
MyPage.java
final Map<String, String> vars = new HashMap<String, String>(1);
vars.put("loginButtonId", "login_button"); // should get the
"login_button" id from component.getMarkupId() instead
return new VelocityHeaderContributor().add(new
VelocityJavascriptContributor(MyPage.class, "path/to/myscript.vm",
Model.valueOf(vars), "nameOfScript"));
-----Original Message-----
From: eyalbenamram [mailto:eyal.benamram@gmail.com]
Sent: Tuesday, October 28, 2008 2:45 PM
To: users@wicket.apache.org
Subject: Re: inserting javascript from java to html file
OK. What if I want all the JS to be inline (no .js file to be made)?
I saw that wicket created a .js file...
igor.vaynberg wrote:
>
> response.renderOnLoadJavascript() takes just the javascript - like the
> javadoc says. no need for you to output the script tags.
>
> -igor
>
> On Tue, Oct 28, 2008 at 11:33 AM, eyalbenamram
> <ey...@gmail.com>
> wrote:
>>
>> public void renderHead(IHeaderResponse response) {
>>
>>
>> StringBuffer config = new StringBuffer();
>>
>> config.append("<script language=\"JavaScript\">\n");
>> config.append("function removeBlur(checked) {\n");
>> config.append("if(checked) {\n");
>>
>> config.append("document.getElementById('login_button').disabled =
>> false;\n");
>> config.append("} else {\n");
>>
>> config.append("document.getElementById('login_button').disabled =
>> true;\n");
>> config.append("} }\n");
>> config.append("</script>\n");
>>
>> response.renderOnLoadJavascript(config.toString());
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> what is your code look like?
>>>
>>> -igor
>>>
>>> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram
>>> <ey...@gmail.com>
>>> wrote:
>>>>
>>>> Hi again,
>>>>
>>>> I used IHeaderContributer, and the javascript code is now garbled
>>>> and not working.
>>>> Here is what I got:
>>>>
>>>> <script type="text/javascript"
>>>> src="resources/org.apache.wicket.markup.html.WicketEventReference/w
>>>> icket-event.js"></script> <script type="text/javascript"
>>>> ><!--/*--><![CDATA[/*><!--*/ Wicket.Event.add(window, "load",
>>>> function() { <script language="JavaScript"> function
>>>> removeBlur(checked) {
>>>> if(checked) {
>>>> document.getElementById('login_button').disabled = false; } else {
>>>> document.getElementById('login_button').disabled = true; } }
>>>> </script> ;}); /*-->]]>*/</script>
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> use iheadercontributor, that should work much better
>>>>>
>>>>> also make sure your page has <body> tag.
>>>>>
>>>>> -igor
>>>>>
>>>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram
>>>>> <ey...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi
>>>>>> I am inserting javascript code like this:
>>>>>>
>>>>>> StringBuffer config = new StringBuffer();
>>>>>>
>>>>>> config.append("<script
language=\"JavaScript\">\n");
>>>>>> config.append("function onLoad() { getValue();
>>>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+");
}\n");
>>>>>> config.append("function onRefresh(){\n");
>>>>>>
>>>>>> config.append("document.getElementById('hiddenVar').value
>>>>>> =
>>>>>> document.getElementById('textString').value;\n");
>>>>>> config.append("window.location.reload(); }\n");
>>>>>> config.append("function getValue() {\n");
>>>>>>
>>>>>> config.append("document.getElementById('textString').value
>>>>>> =
>>>>>> document.getElementById('hiddenVar').value; }\n");
>>>>>> config.append("</script>\n");
>>>>>>
>>>>>> /*open to activate JS*/
>>>>>> add(new
>>>>>> StringHeaderContributor(config.toString()));
>>>>>>
>>>>>>
>>>>>> and receive an error in log file:
>>>>>>
>>>>>> http-6789-2 ERROR html.WebPage -
>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a
>>>>>> <body> or <header> tag to your markup since no Header Container
>>>>>> was found but components where found which want to write to the
>>>>>> <head> section.
>>>>>> <script language="JavaScript">
>>>>>> function removeBlur(checked) {
>>>>>> if(checked) {
>>>>>> document.getElementById('login_button').disabled = false; } else
>>>>>> { document.getElementById('login_button').disabled = true; } }
>>>>>> </script>
>>>>>>
>>>>>> although my html file contains a <head> tag, and the javascript
>>>>>> code actually appears in the rendered page (when I look at the
>>>>>> source of the page).
>>>>>>
>>>>>> any idea?
>>>>>>
>>>>>> Thanks,Eyal.
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file
>>>>>> -tp20212650p20212650.html Sent from the Wicket - User mailing
>>>>>> list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> -----------------------------------------------------------------
>>>>>> ---- To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ------------------------------------------------------------------
>>>>> --- To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-t
>>>> p20212650p20213238.html Sent from the Wicket - User mailing list
>>>> archive at Nabble.com.
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> -- To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp2
>> 0212650p20213326.html Sent from the Wicket - User mailing list
>> archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context:
http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp2021
2650p20213513.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by eyalbenamram <ey...@gmail.com>.
OK. What if I want all the JS to be inline (no .js file to be made)?
I saw that wicket created a .js file...
igor.vaynberg wrote:
>
> response.renderOnLoadJavascript() takes just the javascript - like the
> javadoc says. no need for you to output the script tags.
>
> -igor
>
> On Tue, Oct 28, 2008 at 11:33 AM, eyalbenamram <ey...@gmail.com>
> wrote:
>>
>> public void renderHead(IHeaderResponse response) {
>>
>>
>> StringBuffer config = new StringBuffer();
>>
>> config.append("<script language=\"JavaScript\">\n");
>> config.append("function removeBlur(checked) {\n");
>> config.append("if(checked) {\n");
>>
>> config.append("document.getElementById('login_button').disabled =
>> false;\n");
>> config.append("} else {\n");
>>
>> config.append("document.getElementById('login_button').disabled =
>> true;\n");
>> config.append("} }\n");
>> config.append("</script>\n");
>>
>> response.renderOnLoadJavascript(config.toString());
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> what is your code look like?
>>>
>>> -igor
>>>
>>> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram <ey...@gmail.com>
>>> wrote:
>>>>
>>>> Hi again,
>>>>
>>>> I used IHeaderContributer, and the javascript code is now garbled and
>>>> not
>>>> working.
>>>> Here is what I got:
>>>>
>>>> <script type="text/javascript"
>>>> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
>>>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>>>> Wicket.Event.add(window, "load", function() { <script
>>>> language="JavaScript">
>>>> function removeBlur(checked) {
>>>> if(checked) {
>>>> document.getElementById('login_button').disabled = false;
>>>> } else {
>>>> document.getElementById('login_button').disabled = true;
>>>> } }
>>>> </script>
>>>> ;});
>>>> /*-->]]>*/</script>
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> use iheadercontributor, that should work much better
>>>>>
>>>>> also make sure your page has <body> tag.
>>>>>
>>>>> -igor
>>>>>
>>>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram
>>>>> <ey...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi
>>>>>> I am inserting javascript code like this:
>>>>>>
>>>>>> StringBuffer config = new StringBuffer();
>>>>>>
>>>>>> config.append("<script language=\"JavaScript\">\n");
>>>>>> config.append("function onLoad() { getValue();
>>>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>>>>>> config.append("function onRefresh(){\n");
>>>>>>
>>>>>> config.append("document.getElementById('hiddenVar').value
>>>>>> =
>>>>>> document.getElementById('textString').value;\n");
>>>>>> config.append("window.location.reload(); }\n");
>>>>>> config.append("function getValue() {\n");
>>>>>>
>>>>>> config.append("document.getElementById('textString').value
>>>>>> =
>>>>>> document.getElementById('hiddenVar').value; }\n");
>>>>>> config.append("</script>\n");
>>>>>>
>>>>>> /*open to activate JS*/
>>>>>> add(new StringHeaderContributor(config.toString()));
>>>>>>
>>>>>>
>>>>>> and receive an error in log file:
>>>>>>
>>>>>> http-6789-2 ERROR html.WebPage -
>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body>
>>>>>> or
>>>>>> <header> tag to your markup since no Header Container was
>>>>>> found but components where found which want to write to the <head>
>>>>>> section.
>>>>>> <script language="JavaScript">
>>>>>> function removeBlur(checked) {
>>>>>> if(checked) {
>>>>>> document.getElementById('login_button').disabled = false;
>>>>>> } else {
>>>>>> document.getElementById('login_button').disabled = true;
>>>>>> } }
>>>>>> </script>
>>>>>>
>>>>>> although my html file contains a <head> tag, and the javascript code
>>>>>> actually appears in the rendered page (when I look at the source of
>>>>>> the
>>>>>> page).
>>>>>>
>>>>>> any idea?
>>>>>>
>>>>>> Thanks,Eyal.
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213326.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213513.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by Igor Vaynberg <ig...@gmail.com>.
response.renderOnLoadJavascript() takes just the javascript - like the
javadoc says. no need for you to output the script tags.
-igor
On Tue, Oct 28, 2008 at 11:33 AM, eyalbenamram <ey...@gmail.com> wrote:
>
> public void renderHead(IHeaderResponse response) {
>
>
> StringBuffer config = new StringBuffer();
>
> config.append("<script language=\"JavaScript\">\n");
> config.append("function removeBlur(checked) {\n");
> config.append("if(checked) {\n");
> config.append("document.getElementById('login_button').disabled =
> false;\n");
> config.append("} else {\n");
> config.append("document.getElementById('login_button').disabled =
> true;\n");
> config.append("} }\n");
> config.append("</script>\n");
>
> response.renderOnLoadJavascript(config.toString());
>
>
>
> igor.vaynberg wrote:
>>
>> what is your code look like?
>>
>> -igor
>>
>> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram <ey...@gmail.com>
>> wrote:
>>>
>>> Hi again,
>>>
>>> I used IHeaderContributer, and the javascript code is now garbled and not
>>> working.
>>> Here is what I got:
>>>
>>> <script type="text/javascript"
>>> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
>>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>>> Wicket.Event.add(window, "load", function() { <script
>>> language="JavaScript">
>>> function removeBlur(checked) {
>>> if(checked) {
>>> document.getElementById('login_button').disabled = false;
>>> } else {
>>> document.getElementById('login_button').disabled = true;
>>> } }
>>> </script>
>>> ;});
>>> /*-->]]>*/</script>
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> use iheadercontributor, that should work much better
>>>>
>>>> also make sure your page has <body> tag.
>>>>
>>>> -igor
>>>>
>>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi
>>>>> I am inserting javascript code like this:
>>>>>
>>>>> StringBuffer config = new StringBuffer();
>>>>>
>>>>> config.append("<script language=\"JavaScript\">\n");
>>>>> config.append("function onLoad() { getValue();
>>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>>>>> config.append("function onRefresh(){\n");
>>>>>
>>>>> config.append("document.getElementById('hiddenVar').value
>>>>> =
>>>>> document.getElementById('textString').value;\n");
>>>>> config.append("window.location.reload(); }\n");
>>>>> config.append("function getValue() {\n");
>>>>>
>>>>> config.append("document.getElementById('textString').value
>>>>> =
>>>>> document.getElementById('hiddenVar').value; }\n");
>>>>> config.append("</script>\n");
>>>>>
>>>>> /*open to activate JS*/
>>>>> add(new StringHeaderContributor(config.toString()));
>>>>>
>>>>>
>>>>> and receive an error in log file:
>>>>>
>>>>> http-6789-2 ERROR html.WebPage -
>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
>>>>> <header> tag to your markup since no Header Container was
>>>>> found but components where found which want to write to the <head>
>>>>> section.
>>>>> <script language="JavaScript">
>>>>> function removeBlur(checked) {
>>>>> if(checked) {
>>>>> document.getElementById('login_button').disabled = false;
>>>>> } else {
>>>>> document.getElementById('login_button').disabled = true;
>>>>> } }
>>>>> </script>
>>>>>
>>>>> although my html file contains a <head> tag, and the javascript code
>>>>> actually appears in the rendered page (when I look at the source of the
>>>>> page).
>>>>>
>>>>> any idea?
>>>>>
>>>>> Thanks,Eyal.
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213326.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by eyalbenamram <ey...@gmail.com>.
public void renderHead(IHeaderResponse response) {
StringBuffer config = new StringBuffer();
config.append("<script language=\"JavaScript\">\n");
config.append("function removeBlur(checked) {\n");
config.append("if(checked) {\n");
config.append("document.getElementById('login_button').disabled =
false;\n");
config.append("} else {\n");
config.append("document.getElementById('login_button').disabled =
true;\n");
config.append("} }\n");
config.append("</script>\n");
response.renderOnLoadJavascript(config.toString());
igor.vaynberg wrote:
>
> what is your code look like?
>
> -igor
>
> On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram <ey...@gmail.com>
> wrote:
>>
>> Hi again,
>>
>> I used IHeaderContributer, and the javascript code is now garbled and not
>> working.
>> Here is what I got:
>>
>> <script type="text/javascript"
>> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>> Wicket.Event.add(window, "load", function() { <script
>> language="JavaScript">
>> function removeBlur(checked) {
>> if(checked) {
>> document.getElementById('login_button').disabled = false;
>> } else {
>> document.getElementById('login_button').disabled = true;
>> } }
>> </script>
>> ;});
>> /*-->]]>*/</script>
>>
>>
>>
>> igor.vaynberg wrote:
>>>
>>> use iheadercontributor, that should work much better
>>>
>>> also make sure your page has <body> tag.
>>>
>>> -igor
>>>
>>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com>
>>> wrote:
>>>>
>>>> Hi
>>>> I am inserting javascript code like this:
>>>>
>>>> StringBuffer config = new StringBuffer();
>>>>
>>>> config.append("<script language=\"JavaScript\">\n");
>>>> config.append("function onLoad() { getValue();
>>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>>>> config.append("function onRefresh(){\n");
>>>>
>>>> config.append("document.getElementById('hiddenVar').value
>>>> =
>>>> document.getElementById('textString').value;\n");
>>>> config.append("window.location.reload(); }\n");
>>>> config.append("function getValue() {\n");
>>>>
>>>> config.append("document.getElementById('textString').value
>>>> =
>>>> document.getElementById('hiddenVar').value; }\n");
>>>> config.append("</script>\n");
>>>>
>>>> /*open to activate JS*/
>>>> add(new StringHeaderContributor(config.toString()));
>>>>
>>>>
>>>> and receive an error in log file:
>>>>
>>>> http-6789-2 ERROR html.WebPage -
>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
>>>> <header> tag to your markup since no Header Container was
>>>> found but components where found which want to write to the <head>
>>>> section.
>>>> <script language="JavaScript">
>>>> function removeBlur(checked) {
>>>> if(checked) {
>>>> document.getElementById('login_button').disabled = false;
>>>> } else {
>>>> document.getElementById('login_button').disabled = true;
>>>> } }
>>>> </script>
>>>>
>>>> although my html file contains a <head> tag, and the javascript code
>>>> actually appears in the rendered page (when I look at the source of the
>>>> page).
>>>>
>>>> any idea?
>>>>
>>>> Thanks,Eyal.
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213326.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by Igor Vaynberg <ig...@gmail.com>.
what is your code look like?
-igor
On Tue, Oct 28, 2008 at 11:28 AM, eyalbenamram <ey...@gmail.com> wrote:
>
> Hi again,
>
> I used IHeaderContributer, and the javascript code is now garbled and not
> working.
> Here is what I got:
>
> <script type="text/javascript"
> src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
> Wicket.Event.add(window, "load", function() { <script language="JavaScript">
> function removeBlur(checked) {
> if(checked) {
> document.getElementById('login_button').disabled = false;
> } else {
> document.getElementById('login_button').disabled = true;
> } }
> </script>
> ;});
> /*-->]]>*/</script>
>
>
>
> igor.vaynberg wrote:
>>
>> use iheadercontributor, that should work much better
>>
>> also make sure your page has <body> tag.
>>
>> -igor
>>
>> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com>
>> wrote:
>>>
>>> Hi
>>> I am inserting javascript code like this:
>>>
>>> StringBuffer config = new StringBuffer();
>>>
>>> config.append("<script language=\"JavaScript\">\n");
>>> config.append("function onLoad() { getValue();
>>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>>> config.append("function onRefresh(){\n");
>>> config.append("document.getElementById('hiddenVar').value
>>> =
>>> document.getElementById('textString').value;\n");
>>> config.append("window.location.reload(); }\n");
>>> config.append("function getValue() {\n");
>>> config.append("document.getElementById('textString').value
>>> =
>>> document.getElementById('hiddenVar').value; }\n");
>>> config.append("</script>\n");
>>>
>>> /*open to activate JS*/
>>> add(new StringHeaderContributor(config.toString()));
>>>
>>>
>>> and receive an error in log file:
>>>
>>> http-6789-2 ERROR html.WebPage -
>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
>>> <header> tag to your markup since no Header Container was
>>> found but components where found which want to write to the <head>
>>> section.
>>> <script language="JavaScript">
>>> function removeBlur(checked) {
>>> if(checked) {
>>> document.getElementById('login_button').disabled = false;
>>> } else {
>>> document.getElementById('login_button').disabled = true;
>>> } }
>>> </script>
>>>
>>> although my html file contains a <head> tag, and the javascript code
>>> actually appears in the rendered page (when I look at the source of the
>>> page).
>>>
>>> any idea?
>>>
>>> Thanks,Eyal.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by eyalbenamram <ey...@gmail.com>.
Hi again,
I used IHeaderContributer, and the javascript code is now garbled and not
working.
Here is what I got:
<script type="text/javascript"
src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
<script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
Wicket.Event.add(window, "load", function() { <script language="JavaScript">
function removeBlur(checked) {
if(checked) {
document.getElementById('login_button').disabled = false;
} else {
document.getElementById('login_button').disabled = true;
} }
</script>
;});
/*-->]]>*/</script>
igor.vaynberg wrote:
>
> use iheadercontributor, that should work much better
>
> also make sure your page has <body> tag.
>
> -igor
>
> On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com>
> wrote:
>>
>> Hi
>> I am inserting javascript code like this:
>>
>> StringBuffer config = new StringBuffer();
>>
>> config.append("<script language=\"JavaScript\">\n");
>> config.append("function onLoad() { getValue();
>> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
>> config.append("function onRefresh(){\n");
>> config.append("document.getElementById('hiddenVar').value
>> =
>> document.getElementById('textString').value;\n");
>> config.append("window.location.reload(); }\n");
>> config.append("function getValue() {\n");
>> config.append("document.getElementById('textString').value
>> =
>> document.getElementById('hiddenVar').value; }\n");
>> config.append("</script>\n");
>>
>> /*open to activate JS*/
>> add(new StringHeaderContributor(config.toString()));
>>
>>
>> and receive an error in log file:
>>
>> http-6789-2 ERROR html.WebPage -
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
>> <header> tag to your markup since no Header Container was
>> found but components where found which want to write to the <head>
>> section.
>> <script language="JavaScript">
>> function removeBlur(checked) {
>> if(checked) {
>> document.getElementById('login_button').disabled = false;
>> } else {
>> document.getElementById('login_button').disabled = true;
>> } }
>> </script>
>>
>> although my html file contains a <head> tag, and the javascript code
>> actually appears in the rendered page (when I look at the source of the
>> page).
>>
>> any idea?
>>
>> Thanks,Eyal.
>> --
>> View this message in context:
>> http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20213238.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: inserting javascript from java to html file
Posted by Igor Vaynberg <ig...@gmail.com>.
use iheadercontributor, that should work much better
also make sure your page has <body> tag.
-igor
On Tue, Oct 28, 2008 at 10:57 AM, eyalbenamram <ey...@gmail.com> wrote:
>
> Hi
> I am inserting javascript code like this:
>
> StringBuffer config = new StringBuffer();
>
> config.append("<script language=\"JavaScript\">\n");
> config.append("function onLoad() { getValue();
> setTimeout(\"onRefresh();\","+ns.getAutoRefreshSecs()*1000+"); }\n");
> config.append("function onRefresh(){\n");
> config.append("document.getElementById('hiddenVar').value =
> document.getElementById('textString').value;\n");
> config.append("window.location.reload(); }\n");
> config.append("function getValue() {\n");
> config.append("document.getElementById('textString').value =
> document.getElementById('hiddenVar').value; }\n");
> config.append("</script>\n");
>
> /*open to activate JS*/
> add(new StringHeaderContributor(config.toString()));
>
>
> and receive an error in log file:
>
> http-6789-2 ERROR html.WebPage -
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> http-6789-2 ERROR html.WebPage - You probably forgot to add a <body> or
> <header> tag to your markup since no Header Container was
> found but components where found which want to write to the <head> section.
> <script language="JavaScript">
> function removeBlur(checked) {
> if(checked) {
> document.getElementById('login_button').disabled = false;
> } else {
> document.getElementById('login_button').disabled = true;
> } }
> </script>
>
> although my html file contains a <head> tag, and the javascript code
> actually appears in the rendered page (when I look at the source of the
> page).
>
> any idea?
>
> Thanks,Eyal.
> --
> View this message in context: http://www.nabble.com/inserting-javascript-from-java-to-html-file-tp20212650p20212650.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org