Wicket
  1. Wicket
  2. WICKET-2832

Output wicket attributes even in ajax response

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.7
    • Fix Version/s: 1.5-RC1
    • Component/s: wicket
    • Labels:
      None

      Description

      I am working on a special locator in selenium for Wicket generated pages. For example, one can like wicket:id in a xpath-like locator: //myform//username, which means locating the first element whose wicket:id is "myform" and then locating the first element whose wicket:id is "username".

      The code is working. However, due to WICKET-1174, stripWicketTags in renderComponentTag() is now set to true as long as it is an ajax request. So, if an element is refreshed in an ajax request, it will lose the wicket:id and the locator won't find it.

      To solve the problem, I'd suggest the splitting the concept of "strip wicket attributes" from "strip wicket tags". This way, you can still trip the wicket tags without affecting the wicket:id.

        Issue Links

          Activity

          Hide
          Kent Tong added a comment -

          I've created a custom locator for Selenium to locate elements generated by wicket components easily. For example, wicket=//myform[2]//name will locate the 3rd element with wicket:id="myform" and then locate an element with wicket:id="name". The code is working fine.

          However, due to Wicket-1174, once the element is refreshed by ajax, it will lose the wicket:id and thus the locator will no longer work.

          An easy solution is to separate the concept of "strip wicket attributes" from "strip wicket tags". This way the wicket:id can remain without confusing firefox. This can be done easily in the renderComponentTag() method.

          Show
          Kent Tong added a comment - I've created a custom locator for Selenium to locate elements generated by wicket components easily. For example, wicket=//myform [2] //name will locate the 3rd element with wicket:id="myform" and then locate an element with wicket:id="name". The code is working fine. However, due to Wicket-1174, once the element is refreshed by ajax, it will lose the wicket:id and thus the locator will no longer work. An easy solution is to separate the concept of "strip wicket attributes" from "strip wicket tags". This way the wicket:id can remain without confusing firefox. This can be done easily in the renderComponentTag() method.
          Hide
          Kent Tong added a comment -

          OK, I can apply a workaround by using wicketpath instead.

          Show
          Kent Tong added a comment - OK, I can apply a workaround by using wicketpath instead.
          Hide
          Kent Tong added a comment -

          I've created a patch for it. It is very simple and localized. Please consider.

          Show
          Kent Tong added a comment - I've created a patch for it. It is very simple and localized. Please consider.
          Hide
          Kent Tong added a comment -

          It will make the behavior of wicket more consistent (wicket:id still generated even if it's ajax).

          Show
          Kent Tong added a comment - It will make the behavior of wicket more consistent (wicket:id still generated even if it's ajax).
          Hide
          Martin Grigorov added a comment -

          Actually the patch here is much simpler:

          diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
          index 3c98cf6..7c35b82 100644
          — a/wicket-core/src/main/java/org/apache/wicket/Component.java
          +++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
          @@ -2535,8 +2534,8 @@ public abstract class Component
          boolean renderTag = (openTag == null ? false : !(openTag instanceof WicketTag));
          if (renderTag == false)

          { - renderTag = !((getRequest() instanceof WebRequest) && ((WebRequest)getRequest()).isAjax()); - renderTag &= !getApplication().getMarkupSettings().getStripWicketTags(); + renderTag = !getApplication().getMarkupSettings().getStripWicketTags(); }

          This way only the application setting is used to decide whether to render wicket:xx attributes/tags.
          All core tests passed without failures (re-generation of expected .html is needed though!).

          @Juergen: do you remember why the check for 'isAjax' is used here ? Git blame says you added this code at 23 Oct 2009.

          Show
          Martin Grigorov added a comment - Actually the patch here is much simpler: diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java index 3c98cf6..7c35b82 100644 — a/wicket-core/src/main/java/org/apache/wicket/Component.java +++ b/wicket-core/src/main/java/org/apache/wicket/Component.java @@ -2535,8 +2534,8 @@ public abstract class Component boolean renderTag = (openTag == null ? false : !(openTag instanceof WicketTag)); if (renderTag == false) { - renderTag = !((getRequest() instanceof WebRequest) && ((WebRequest)getRequest()).isAjax()); - renderTag &= !getApplication().getMarkupSettings().getStripWicketTags(); + renderTag = !getApplication().getMarkupSettings().getStripWicketTags(); } This way only the application setting is used to decide whether to render wicket:xx attributes/tags. All core tests passed without failures (re-generation of expected .html is needed though!). @Juergen: do you remember why the check for 'isAjax' is used here ? Git blame says you added this code at 23 Oct 2009.
          Hide
          Juergen Donnerstag added a comment -

          this code exists since we introduced ajax. Back than we were careful and tried to avoid unforseen side effects.

          Show
          Juergen Donnerstag added a comment - this code exists since we introduced ajax. Back than we were careful and tried to avoid unforseen side effects.
          Hide
          Martin Grigorov added a comment -

          Improved with r1053639 in Wicket 1.5.

          Show
          Martin Grigorov added a comment - Improved with r1053639 in Wicket 1.5.

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Kent Tong
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development