Re: How to do Simple non-Ajax Javascript Behaviour?
Hi, Yes, it's a direct paste. I've regenerated the page and this is the output at HTML. http://localhost:/mirage/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js>"> ]]>*/ I added the both types of quotes but still don't get the event firing. http://localhost:/mirage/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js>"> ]]>*/ http://localhost:/mirage/resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js>"> ]]>*/ So it seems that the event monitor in not working for keyup in my code. I've followed Martin's hint and managed to get the event firing by adding an attribute modified to onkeyup to the textfield so I guess that's a solution. Thanks for that one. Lester Igor Vaynberg wrote: does your page have a
Re: How to do Simple non-Ajax Javascript Behaviour?
does your page have a
Re: How to do Simple non-Ajax Javascript Behaviour?
Hi Martin, Thanks for the hint, I'll look that up. In fact, I could do onkeyup onto the markup on the html directly but wanted to do it the wicket way =) as well as reliably obtain my markupid without cluttering the my markups with JS all over the place. On further investigation, using the approach described below I get Wicket.Event.add(tagNo2f, "keyup", function(event) { alert('Key Up!');;}); Added in my page. This is done automatically. So it seems to be adding the event to the event monitoring code. It's just not firing. Did I miss out something obvious? Lester Martin Makundi wrote: YOu need to make AttributeModifier if you want it to look like this: ** Martin 2009/12/2 Lester Chua : Hi, Hmmm, I have a simple thing which should be easy but I just cant figure out on Wicket. 1. I have an input box. 2. I need to "attach" a javascript to this box to monitor key presses. Basically I need to fire a js on the keyup event. I've googled but have not found the answer to a basically simple thing. I've tried the following which I realise wont work since the rendering should not be into the header (or should it?) public class KeyPressTagBehavior extends AbstractBehavior { private static final long serialVersionUID = 262920170424255562L; private Component component; public void bind(Component component) { this.component = component; component.setOutputMarkupId(true); } public void renderHead(IHeaderResponse iHeaderResponse) { super.renderHead(iHeaderResponse); iHeaderResponse.renderOnEventJavascript( component.getMarkupId(), "keyup", "alert('Key Up!')"); } } Then done a simple TextField field = new TextField("somefield"); field.add(new KeyPressTagBehavior()); I realised that the renderHead will render into the head. But cant find a reference in the API to let me add it into the TextField. What is the correct way to do this? Regards, Lester - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to do Simple non-Ajax Javascript Behaviour?
YOu need to make AttributeModifier if you want it to look like this: ** Martin 2009/12/2 Lester Chua : > Hi, > > Hmmm, I have a simple thing which should be easy but I just cant figure out > on Wicket. > > 1. I have an input box. > 2. I need to "attach" a javascript to this box to monitor key presses. > Basically I need to fire a js on the keyup event. > > I've googled but have not found the answer to a basically simple thing. > I've tried the following which I realise wont work since the rendering > should not be into the header (or should it?) > > public class KeyPressTagBehavior extends AbstractBehavior > { > private static final long serialVersionUID = 262920170424255562L; > private Component component; > > public void bind(Component component) > { > this.component = component; > component.setOutputMarkupId(true); > } > > public void renderHead(IHeaderResponse iHeaderResponse) > { > super.renderHead(iHeaderResponse); > iHeaderResponse.renderOnEventJavascript( > component.getMarkupId(), > "keyup", > "alert('Key Up!')"); } > } > > > Then done a simple > > TextField field = new TextField("somefield"); > field.add(new KeyPressTagBehavior()); > > I realised that the renderHead will render into the head. But cant find a > reference in the API to let me add it into the TextField. What is the > correct way to do this? > > Regards, > > Lester > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org