Re: wrapping onclick in AjaxLink with 1.5.4

2012-02-29 Thread armhold
Hi Martin,

I'm following the example 
https://cwiki.apache.org/WICKET/calling-javascript-function-on-wicket-components-onclick.html
shown here . My code is literally that, added to the prototypical Wicket
Quickstart HomePage.java:

public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;

public HomePage(final PageParameters parameters) {
add(new Label(version,
getApplication().getFrameworkSettings().getVersion()));

AjaxLink ajaxLink = new AjaxLink(ajaxLink) {

@Override
public void onClick(AjaxRequestTarget target)
{
System.out.println(onClick fired);
}

protected IAjaxCallDecorator getAjaxCallDecorator() {
return new AjaxCallDecorator() {
public CharSequence decorateScript(CharSequence script)
{
return alert('This is my javascript call');  +
script;
}
};
}
};

add(ajaxLink);
}
}

If I inspect the generated HTML, it looks like this:

# This is an ajax link. 

Thanks for your time.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wrapping-onclick-in-AjaxLink-with-1-5-4-tp4430306p4431400.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: wrapping onclick in AjaxLink with 1.5.4

2012-02-29 Thread Martin Grigorov
On Wed, Feb 29, 2012 at 2:53 PM, armhold armh...@gmail.com wrote:
 Hi Martin,

 I'm following the example
 https://cwiki.apache.org/WICKET/calling-javascript-function-on-wicket-components-onclick.html
 shown here . My code is literally that, added to the prototypical Wicket
 Quickstart HomePage.java:

 public class HomePage extends WebPage {
        private static final long serialVersionUID = 1L;

    public HomePage(final PageParameters parameters) {
                add(new Label(version,
 getApplication().getFrameworkSettings().getVersion()));

        AjaxLink ajaxLink = new AjaxLink(ajaxLink) {

            @Override
            public void onClick(AjaxRequestTarget target)
            {
                System.out.println(onClick fired);
            }

            protected IAjaxCallDecorator getAjaxCallDecorator() {
                return new AjaxCallDecorator() {
                    public CharSequence decorateScript(CharSequence script)

Put @Override on the line above and you will see that the compiler complains.
Please update the wiki with the new signature for 1.5

 {
                        return alert('This is my javascript call');  +
 script;
                    }
                };
            }
        };

        add(ajaxLink);
    }
 }

 If I inspect the generated HTML, it looks like this:

 # This is an ajax link.

 Thanks for your time.


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/wrapping-onclick-in-AjaxLink-with-1-5-4-tp4430306p4431400.html
 Sent from the Users forum mailing list archive at Nabble.com.

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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: wrapping onclick in AjaxLink with 1.5.4

2012-02-29 Thread armhold
Well that was simple, thank you.  I'm pedantic enough to have added @Override
to the getAjaxCallDecorator(), but I missed decorateScript() in my initial
attempt.

The method is being called now, and I have updated the Wiki. 

However the second example listed on the Wiki (AttributeAppender) also does
not work.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wrapping-onclick-in-AjaxLink-with-1-5-4-tp4430306p4431489.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: wrapping onclick in AjaxLink with 1.5.4

2012-02-29 Thread Martin Grigorov
On Wed, Feb 29, 2012 at 3:28 PM, armhold armh...@gmail.com wrote:
 Well that was simple, thank you.  I'm pedantic enough to have added @Override
 to the getAjaxCallDecorator(), but I missed decorateScript() in my initial
 attempt.

 The method is being called now, and I have updated the Wiki.

 However the second example listed on the Wiki (AttributeAppender) also does
 not work.

I'm not sure whether it ever worked. It is not possible to add several
behaviors on the same component that manipulate the same attribute.



 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/wrapping-onclick-in-AjaxLink-with-1-5-4-tp4430306p4431489.html
 Sent from the Users forum mailing list archive at Nabble.com.

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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



wrapping onclick in AjaxLink with 1.5.4

2012-02-28 Thread armhold
Hi,

I need to run some Javascript on the client when the user clicks an
AjaxLink. I'm following 
https://cwiki.apache.org/WICKET/calling-javascript-function-on-wicket-components-onclick.html
these instructions , but my onclick() javascript always gets overwritten by
the AjaxLink's behavior.

I tried overriding getAjaxCallDecorator() as well as adding an
AttributeAppender, and neither seem to work. Nor does adding the appender in
onInitialize(), as 
http://apache-wicket.1842946.n4.nabble.com/AttributeModifier-and-AjaxLink-in-1-5-td3830027.html
this thread  recommends.

Thanks for any advice.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wrapping-onclick-in-AjaxLink-with-1-5-4-tp4430306p4430306.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: wrapping onclick in AjaxLink with 1.5.4

2012-02-28 Thread Martin Grigorov
Hi,

You need to override AjaxLink's #getAjaxCallDecorator(). With it you
can add you script to be executed before or after the real script that
will call AjaxLink#onClick.
Show some code if you still cannot manage it.

On Wed, Feb 29, 2012 at 4:14 AM, armhold armh...@gmail.com wrote:
 Hi,

 I need to run some Javascript on the client when the user clicks an
 AjaxLink. I'm following
 https://cwiki.apache.org/WICKET/calling-javascript-function-on-wicket-components-onclick.html
 these instructions , but my onclick() javascript always gets overwritten by
 the AjaxLink's behavior.

 I tried overriding getAjaxCallDecorator() as well as adding an
 AttributeAppender, and neither seem to work. Nor does adding the appender in
 onInitialize(), as
 http://apache-wicket.1842946.n4.nabble.com/AttributeModifier-and-AjaxLink-in-1-5-td3830027.html
 this thread  recommends.

 Thanks for any advice.


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/wrapping-onclick-in-AjaxLink-with-1-5-4-tp4430306p4430306.html
 Sent from the Users forum mailing list archive at Nabble.com.

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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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