You need to attach the event to a tag in the markup. Since the Page
component is not directly attached to any tag then you can't use that.
Instead use:
public class Index extends WebPage
{
public Index()
{
super();
final Label testLabel = new Label(this, "message", "Hello
World");
testLabel.setOutputMarkupId(true);
getBodyContainer().getBodyContainer().add(new
AjaxEventBehavior(ClientEvent.KEYPRESS)
{
protected void onEvent(final AjaxRequestTarget target)
{
target.addComponent(testLabel);
target.appendJavascript("new Effect.Highlight($('" +
testLabel.getMarkupId() + "'));");
}
});
}
}
PLEASE note the two levels of getBodyContainer(). Both are needed.
Frank
On 10/19/06, Matthew P. Tilchen <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I am not certain as to whether this post will end up being a bug
> report or a feature request but hopefully one of you may have some
> advice.
> Ultimately I am trying to invoke ajax calls as a result of capturing
> "onkeypress" events fired by the document object. I have successfully
> achieved this on components other than Page components but I can not
> get it to work on Page objects. Here is the code for the Page
> subclass that I am speaking of:
>
> public class Index extends WebPage
> {
> public Index()
> {
> super();
>
> final Label testLabel = new Label(this, "message", "Hello
> World");
> testLabel.setOutputMarkupId(true);
>
> add(new AjaxEventBehavior(ClientEvent.KEYPRESS)
> {
> protected void onEvent(final AjaxRequestTarget target)
> {
> target.addComponent(testLabel);
> target.appendJavascript("new Effect.Highlight($('" +
> testLabel.getMarkupId() + "'));");
> }
> });
> }
> }
>
> My assumption is that the "onEvent" method will be invoked when the
> Page (or document in JS) fires a "onkeypress" event. Attempting to
> trigger the behavior on the loaded page does not invoke "onEvent" and
> the in page AJAX debugger shows no activity either.
>
> Has anyone else attempted this type of thing? If this is currently
> not supported it seems like this is something that would be
> consistent with Wicket Ajax implementation's design and I would love
> to see it added.
>
> Thanks.
>
> -MT
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user