You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jason Novotny <no...@gridsphere.org> on 2009/04/18 00:57:28 UTC
changing style of ajax link
Hi,
I have code to create an ajax link and I want it to dynamically adjust
its css class when clicked. This doesn't work since I don't think the
onComponentTag is being called.
final AjaxLink link = new AjaxLink("navlink") {
@Override
public void onClick(AjaxRequestTarget target) {
}
public void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if (foo == 77) {
tag.put("class", "secondaryCurrent");
}
}
};
Any help is greatly appreciated!
Thanks, Jason
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: changing style of ajax link
Posted by James Carman <jc...@carmanconsulting.com>.
By the way, I tested this out and it works. Just use a model that you
can change (perhaps a property model) in your onClick() method.
On Fri, Apr 17, 2009 at 11:41 PM, James Carman
<jc...@carmanconsulting.com> wrote:
> Couldn't you use an AttributeModifier behavior? The value of the
> attribute can be obtained from a model. Just make sure you update the
> link itself inside the onClick()
>
> On Fri, Apr 17, 2009 at 11:30 PM, Jeremy Thomerson
> <je...@wickettraining.com> wrote:
>> try something like this:
>>
>> onClick(AjaxRequestTarget art) {
>> art.appendJavascript("document.getElementById('" + getMarkupId() +
>> "').className='yourcssclass'");
>> }
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>>
>> On Fri, Apr 17, 2009 at 5:57 PM, Jason Novotny <no...@gridsphere.org>wrote:
>>
>>>
>>> Hi,
>>>
>>> I have code to create an ajax link and I want it to dynamically adjust its
>>> css class when clicked. This doesn't work since I don't think the
>>> onComponentTag is being called.
>>>
>>> final AjaxLink link = new AjaxLink("navlink") {
>>> @Override
>>> public void onClick(AjaxRequestTarget target) {
>>>
>>> }
>>>
>>> public void onComponentTag(ComponentTag tag) {
>>> super.onComponentTag(tag);
>>> if (foo == 77) {
>>> tag.put("class", "secondaryCurrent");
>>> }
>>> }
>>>
>>> };
>>>
>>> Any help is greatly appreciated!
>>>
>>> Thanks, Jason
>>>
>>> ---------------------------------------------------------------------
>>> 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: changing style of ajax link
Posted by James Carman <jc...@carmanconsulting.com>.
Couldn't you use an AttributeModifier behavior? The value of the
attribute can be obtained from a model. Just make sure you update the
link itself inside the onClick()
On Fri, Apr 17, 2009 at 11:30 PM, Jeremy Thomerson
<je...@wickettraining.com> wrote:
> try something like this:
>
> onClick(AjaxRequestTarget art) {
> art.appendJavascript("document.getElementById('" + getMarkupId() +
> "').className='yourcssclass'");
> }
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Fri, Apr 17, 2009 at 5:57 PM, Jason Novotny <no...@gridsphere.org>wrote:
>
>>
>> Hi,
>>
>> I have code to create an ajax link and I want it to dynamically adjust its
>> css class when clicked. This doesn't work since I don't think the
>> onComponentTag is being called.
>>
>> final AjaxLink link = new AjaxLink("navlink") {
>> @Override
>> public void onClick(AjaxRequestTarget target) {
>>
>> }
>>
>> public void onComponentTag(ComponentTag tag) {
>> super.onComponentTag(tag);
>> if (foo == 77) {
>> tag.put("class", "secondaryCurrent");
>> }
>> }
>>
>> };
>>
>> Any help is greatly appreciated!
>>
>> Thanks, Jason
>>
>> ---------------------------------------------------------------------
>> 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: changing style of ajax link
Posted by Jeremy Thomerson <je...@wickettraining.com>.
try something like this:
onClick(AjaxRequestTarget art) {
art.appendJavascript("document.getElementById('" + getMarkupId() +
"').className='yourcssclass'");
}
--
Jeremy Thomerson
http://www.wickettraining.com
On Fri, Apr 17, 2009 at 5:57 PM, Jason Novotny <no...@gridsphere.org>wrote:
>
> Hi,
>
> I have code to create an ajax link and I want it to dynamically adjust its
> css class when clicked. This doesn't work since I don't think the
> onComponentTag is being called.
>
> final AjaxLink link = new AjaxLink("navlink") {
> @Override
> public void onClick(AjaxRequestTarget target) {
>
> }
>
> public void onComponentTag(ComponentTag tag) {
> super.onComponentTag(tag);
> if (foo == 77) {
> tag.put("class", "secondaryCurrent");
> }
> }
>
> };
>
> Any help is greatly appreciated!
>
> Thanks, Jason
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: changing style of ajax link
Posted by Martijn Dashorst <ma...@gmail.com>.
a link doesn't repaint itself automatically, you have to add it to the
AjaxRequestTarget in the onclick handler.
Martijn
On Sat, Apr 18, 2009 at 12:57 AM, Jason Novotny <no...@gridsphere.org> wrote:
>
> Hi,
>
> I have code to create an ajax link and I want it to dynamically adjust its
> css class when clicked. This doesn't work since I don't think the
> onComponentTag is being called.
>
> final AjaxLink link = new AjaxLink("navlink") {
> @Override
> public void onClick(AjaxRequestTarget target) {
>
> }
>
> public void onComponentTag(ComponentTag tag) {
> super.onComponentTag(tag);
> if (foo == 77) {
> tag.put("class", "secondaryCurrent");
> }
> }
>
> };
>
> Any help is greatly appreciated!
>
> Thanks, Jason
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org