java - Wicket: How to change label's text on textarea's onkeyup? -


How do I change the text of labels on textarea's onkeyup? I have tried to do this but it does not work:

  form form; Textare Ta; MyLabel results; / ** * The creator to be applied to the page without applying a session. * / Public Homepage (Last Page Parameter Parameter) {this.form = New Form ("Form"); This.ta = new textiera ("text"); This.resultDiv = New MyLabel ("Results"); This.ta.add (new AjaxEventBehavior ("onKeyUp") {protected void onEvent (AjaxRequestTarget target) {System.out.println ("Ajax!"); ResultsDiv.seetext ("Foobar"); resultDiv.renderComponent ();} }); Form.add (ta); Form.add (resultdiv); Add (form); } // constant public class MyLabel label {private string text = "original"; Public string getText () {return text; } Public Zero Set Text (String Text) {this.text = text; } Public MyLabel (string id) {super}; This.setModel (new property model (this, "text")); }}  

Solution

Leonidov was almost there. The result code is:

  form form; Textare Ta; Label resultdivid = new label ("result", new property model (this, "label text")) {{setOutputMarkupId (true); }}; Private string label text = "original"; / ** * The creator to be applied to the page without applying a session. * / Public Homepage (Last Page Parameter Parameter) {this.form = New Form ("Form"); This.ta = new textiera ("text"); This.ta.add (New AjaxEventBehavior ("onKeyUp") {Safe void at Aven (AjaxRequestTarget Goal) {System.out.println ("Ajax!"); LabelText = "Foobar"; // Also No Received / Set Required That's great. Target.addComponent (resultDiv); //resultDiv.renderComponent (); //WRONG !!}}); Form.add (ta); Form.add (resultdiv); Add (form);  

By the way, the result will soon work as a sandbox.

Thanks for the help!

If you want to update the component after the AJAX event, then you have to do 2 things: < / P>

  1. Flagged components should be set to flag setOutputMarkupId == true;
  2. You must add this component to target event methods

      this.resultDiv.setMarkupOutputId (true); Safe Wide OnAge (AjaxRexist Target Goal) {System.out.println ("Ajax!"); //resultDiv.setModel (); ResultDiv.setText ("Foobar"); ResultDiv.renderComponent (); Target.add (resultDiv); }  

PS I do not understand many parts of your code.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -