Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-3626

Attaching AjaxEventBehavior or AjaxFormComponentUpdatingBehavior causes erratic focus in TextArea

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.4.17
    • Fix Version/s: None
    • Component/s: wicket
    • Labels:
    • Environment:
      Firefox 3.6.16, Mac OS X 10.6.6

      Description

      The TextArea is set for 8 rows. Enter 9 rows worth of text (with CR/LF to separate each line). Once you hit the scroll point, and enter another character, the TextArea scrolls back up the top of the viewport. Now put the cursor at the end of line 1. Start typing - the behavior is more erratic than before. Wicket debug window shows a couple of refocus operations (output at end)

      Sample Page:
      ===========

      private String textAreaStr = "No Text";
      private String labelStr = "";

      public DevPage()
      {
      Form form = new Form( "form" );
      add( form );

      final Label label = new Label( "textArea", new PropertyModel<String>( this, "labelStr" ) );
      label.setOutputMarkupId( true );
      label.setEscapeModelStrings( false );
      add( label );

      TextArea textArea = new TextArea( "test", new PropertyModel<String>( this, "textAreaStr" ) );
      form.add( textArea );

      AjaxFormComponentUpdatingBehavior formComponentUpdatingBehavior = new AjaxFormComponentUpdatingBehavior( "onkeyup" )
      {
      @Override
      protected void onUpdate( AjaxRequestTarget target )

      { labelStr = textAreaStr; target.addComponent( label ); }

      };

      formComponentUpdatingBehavior.setThrottleDelay( Duration.milliseconds( 100 ) );
      textArea.add( formComponentUpdatingBehavior );
      }

      Sample HTML:
      ===========

      <wicket:extend>

      <form wicket:id="form">
      <textarea wicket:id="test" rows="8" cols="80"></textarea>
      </form>
      <div wicket:id="textArea"></div>

      </wicket:extend>

      Wicket Ajax Debug Output:
      =====================

      INFO: focus set on teste
      INFO:
      INFO: Initiating Ajax POST request on ?wicket:interface=:3:form:test::IBehaviorListener:0:&random=0.5912934137918602
      INFO: Invoking pre-call handler(s)...
      INFO: Received ajax response (191 characters)
      INFO:
      <?xml version="1.0" encoding="UTF-8"?><ajax-response><component id="textAreaf" ><![CDATA[<div id="textAreaf">No Text
      More Text
      3
      4
      5
      6
      7
      8
      9s
      0
      10

      12

      13</div>]]></component></ajax-response>
      INFO: Response parsed. Now invoking steps...
      INFO: returned focused element: [object HTMLTextAreaElement]
      INFO: returned focused element: [object HTMLTextAreaElement]
      INFO: Response processed successfully.
      INFO: Invoking post-call handler(s)...
      INFO: refocus last focused component not needed/allowed

        Attachments

          Activity

            People

            • Assignee:
              ivaynberg Igor Vaynberg
              Reporter:
              nickpratt Nick Pratt
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: