You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nickponico <sc...@gmail.com> on 2008/11/05 12:25:10 UTC
Re: adding extra javascript call in CheckBox
Hi all, i have to do same thing.
I have to call an external javascript function on "onClick" method of the
checkbox.
i'm using a 1.2.6 version of apache wicket, and in this version the class
CheckBox has method onComponentTag with "final" modifier.
So i can't override this method.
Is there any other way to do this? (naturally without change my apache
wicket version )
Thanks in advance
E.
>
> new CheckBox("checkBox", new Model()) {
> protected void onComponentTag(ComponentTag tag) {
> tag.put("onclick","executeSomething();");
> }
>
>
--
View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20339961.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: adding extra javascript call in CheckBox
Posted by Ernesto Reinaldo Barreiro <er...@fcc.es>.
Do you get a JavaScript error? Maybe
document.getElementById("myDiv").className="visible";
will do the trick...
Ernesto
nickponico wrote:
> I've inserted this simple function in head of html:
>
> <script type="text/javascript">
> function show()
> {
> document.getElementById("myDiv").setAttribute("class", "visible");
> }
> </script>
> </head>
>
> and i'd like to execute this function on onlick...
>
> so somthing like: onlclick="show()"
>
> This is a particular situation, but very important for my GUI.
>
> Thanks
>
> E.
>
>
>
> jwcarman wrote:
>
>> What javascript do you want to put into your onclick handler?
>>
>>
>>
>
>
*************************************************************
Este correo ha sido procesado por el antivirus del Grupo FCC.
*************************************************************
Re: adding extra javascript call in CheckBox
Posted by James Carman <ja...@carmanconsulting.com>.
So, why can't you use AttributeModifier to set the onclick text?
On Wed, Nov 5, 2008 at 7:37 AM, nickponico <sc...@gmail.com> wrote:
>
> I've inserted this simple function in head of html:
>
> <script type="text/javascript">
> function show()
> {
> document.getElementById("myDiv").setAttribute("class", "visible");
> }
> </script>
> </head>
>
> and i'd like to execute this function on onlick...
>
> so somthing like: onlclick="show()"
>
> This is a particular situation, but very important for my GUI.
>
> Thanks
>
> E.
>
>
>
> jwcarman wrote:
>>
>> What javascript do you want to put into your onclick handler?
>>
>>
>
> --
> View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20340933.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: adding extra javascript call in CheckBox
Posted by nickponico <sc...@gmail.com>.
I've inserted this simple function in head of html:
<script type="text/javascript">
function show()
{
document.getElementById("myDiv").setAttribute("class", "visible");
}
</script>
</head>
and i'd like to execute this function on onlick...
so somthing like: onlclick="show()"
This is a particular situation, but very important for my GUI.
Thanks
E.
jwcarman wrote:
>
> What javascript do you want to put into your onclick handler?
>
>
--
View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20340933.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: adding extra javascript call in CheckBox
Posted by James Carman <ja...@carmanconsulting.com>.
What javascript do you want to put into your onclick handler?
On Wed, Nov 5, 2008 at 6:39 AM, nickponico <sc...@gmail.com> wrote:
>
> Thank you for your reply.
>
> Yes there is the Attribute Modifier, but i don't think it can help me.
>
> I try to explain shortly the problem:
>
> I have to modify a css class of a specific div: the DIV can't be managed by
> wicket (with wicket id), but only on html.
>
> So i created a little javascript function that change the css class, and i
> would like to execute it when a user clicks on a CheckBox.
>
> Since i can't manage function (and div) by wicket... i have some
> difficulties to associate it an attributeModifier.
>
> right?
>
> or do i forget something?
>
> thanks
>
>
> jwcarman wrote:
>>
>> Is AttributeModifier not available in 1.2.x?
>>
>
> --
> View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20340173.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: adding extra javascript call in CheckBox
Posted by Ernesto Reinaldo Barreiro <er...@fcc.es>.
Following example does almost what you want (if I didn;t get you wrong).
ChangeColorPanel.html
<wicket:panel>
<div>
<span wicket:id="colorPanel" style=" width: 10px; height: 10px;
background-color: red;">
</span>
<span wicket:id="red" onclick="">
Red
</span>
<span wicket:id="blue" onclick="">
Blue
</span>
<span wicket:id="green" onclick="">
Green
</span>
</div>
</wicket:panel>
ChangeColorPanel.java
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
/**
* @author EReinaldoB
*
*/
public class ChangeColorPanel extends Panel {
private static final long serialVersionUID = 1L;
private WebMarkupContainer colorPanel;
/**
* @param id
*/
public ChangeColorPanel(String id) {
super(id);
colorPanel = new WebMarkupContainer("colorPanel");
colorPanel.setOutputMarkupId(true);
add(colorPanel);
WebMarkupContainer red = new WebMarkupContainer("red");
red.add(new AttributeModifier("onclick", new
AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
String id = colorPanel.getMarkupId();
return "document.getElementById('" + id +
"').style.backgroundColor='red'";
}
}));
add(red);
WebMarkupContainer blue = new WebMarkupContainer("blue");
blue.add(new AttributeModifier("onclick", new
AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
String id = colorPanel.getMarkupId();
return "document.getElementById('" + id +
"').style.backgroundColor='blue'";
}
}));
add(blue);
WebMarkupContainer green = new WebMarkupContainer("green");
green.add(new AttributeModifier("onclick", new
AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
String id = colorPanel.getMarkupId();
return "document.getElementById('" + id +
"').style.backgroundColor='green'";
}
}));
add(green);
}
}
if you replace the first span by a div a the the later spans by check
boxes and intead of modifying the style.backgroundColor you modify the
'className' to the css name you want, I guess this is what you want?
This example works (I tested before posting it ;-) )
Best
Ernesto
nickponico wrote:
> Thank you for your reply.
>
> Yes there is the Attribute Modifier, but i don't think it can help me.
>
> I try to explain shortly the problem:
>
> I have to modify a css class of a specific div: the DIV can't be managed by
> wicket (with wicket id), but only on html.
>
> So i created a little javascript function that change the css class, and i
> would like to execute it when a user clicks on a CheckBox.
>
> Since i can't manage function (and div) by wicket... i have some
> difficulties to associate it an attributeModifier.
>
> right?
>
> or do i forget something?
>
> thanks
>
>
> jwcarman wrote:
>
>> Is AttributeModifier not available in 1.2.x?
>>
>>
>
>
*************************************************************
Este correo ha sido procesado por el antivirus del Grupo FCC.
*************************************************************
Re: adding extra javascript call in CheckBox
Posted by nickponico <sc...@gmail.com>.
Ok... only now i've understood my mistake...
I've had to use a WebmarkupContainer for my div and later use an Attribute
Modifier.
I didn't know WebMarkupContainer component usage.
Thanks to all for replies.
bye
E.
Ernesto Reinaldo Barreiro-3 wrote:
>
> Why you cannot add a WebMarkupConatiner to the div?
>
--
View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20342436.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: adding extra javascript call in CheckBox
Posted by Ernesto Reinaldo Barreiro <er...@fcc.es>.
nickponico wrote:
> Thank you for your reply.
>
> Yes there is the Attribute Modifier, but i don't think it can help me.
>
> I try to explain shortly the problem:
>
> I have to modify a css class of a specific div: the DIV can't be managed by
> wicket (with wicket id), but only on html.
>
What do you mean by that? Why you cannot add a WebMarkupConatiner to the
div? And additionally if you do setOutputMarkupId(true) you could use
the generated id to do what you wnat in a (generated) javaScript
function. I do such tricks all the time...
Ernesto
*************************************************************
Este correo ha sido procesado por el antivirus del Grupo FCC.
*************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: adding extra javascript call in CheckBox
Posted by nickponico <sc...@gmail.com>.
Thank you for your reply.
Yes there is the Attribute Modifier, but i don't think it can help me.
I try to explain shortly the problem:
I have to modify a css class of a specific div: the DIV can't be managed by
wicket (with wicket id), but only on html.
So i created a little javascript function that change the css class, and i
would like to execute it when a user clicks on a CheckBox.
Since i can't manage function (and div) by wicket... i have some
difficulties to associate it an attributeModifier.
right?
or do i forget something?
thanks
jwcarman wrote:
>
> Is AttributeModifier not available in 1.2.x?
>
--
View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20340173.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: adding extra javascript call in CheckBox
Posted by James Carman <ja...@carmanconsulting.com>.
Is AttributeModifier not available in 1.2.x?
On Wed, Nov 5, 2008 at 6:25 AM, nickponico <sc...@gmail.com> wrote:
>
>
> Hi all, i have to do same thing.
>
> I have to call an external javascript function on "onClick" method of the
> checkbox.
>
> i'm using a 1.2.6 version of apache wicket, and in this version the class
> CheckBox has method onComponentTag with "final" modifier.
>
> So i can't override this method.
>
> Is there any other way to do this? (naturally without change my apache
> wicket version )
>
> Thanks in advance
>
> E.
>
>
>
>>
>> new CheckBox("checkBox", new Model()) {
>> protected void onComponentTag(ComponentTag tag) {
>> tag.put("onclick","executeSomething();");
>> }
>>
>>
>
> --
> View this message in context: http://www.nabble.com/adding-extra-javascript-call-in-CheckBox-tp15318650p20339961.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