Wicket
  1. Wicket
  2. WICKET-4100

When using Wicket in a portlet, CheckGroup loses it`s value when some field is in error

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.4.18
    • Fix Version/s: None
    • Component/s: wicket
    • Labels:
    • Environment:
      Liferay 6.0.5 and Liferay 6.0.6 bundled with Tomcat

      Description

      Since in Liferay we can configure the portlets to redirect to view after an action request, and, differently from a standard web application, the page is generated during the response phase, when a component have some validation error in a form, the CheckGroups that are part of this form loose it's values.

      This is due to the fact that Check component, in it's onComponentTag() method, uses getInputAsArray(), which get the request parameters. However, during the render phase, the request parameters are lost when the portlet redirects to view after processing an action.

      This problem manifests also when using an FileUploadField in the form, independently of the redirect-after-post configuration.

      To workaround, I changed the onComponentTag of the Check component to use CheckGroup's getRawInput() instead of getInputAsArray, since the rawInput is also serialized with the component:

      if (group.hasRawInput())
      {
      String[] input;
      if (group.getRawInput() != null)
      input = group.getRawInput().split(FormComponent.VALUE_SEPARATOR);
      else
      input = new String[0];

      I do not know if this is the correct workaround, but, using this way, solved the problem for me.

        Activity

        Robson Miranda created issue -
        Robson Miranda made changes -
        Field Original Value New Value
        Original Estimate 24h [ 86400 ]
        Remaining Estimate 24h [ 86400 ]
        Description Since in Liferay we can configure the portlets to redirect to view after an action request, and, differently from a standard web application, the page is generated during the response phase, when a component have some validation error in a form, the CheckGroups that are part of this form loose it's values.

        This is due to the Check component, in it's onComponentTag() method, uses getInputAsArray(), which get the request parameters. However, during the render phase, the request parameters are lost when the portlet redirects to view after processing an action.

        This problem manifests also when using an FileUploadField in the form, independently of the redirect-after-post configuration.

        To workaround, I changed the onComponentTag of the Check component to use CheckGroup's getRawInput() instead of getInputAsArray, since the rawInput is also serialized with the component:

        if (group.hasRawInput())
        {
        String[] input;
        if (group.getRawInput() != null)
        input = group.getRawInput().split(FormComponent.VALUE_SEPARATOR);
        else
        input = new String[0];

        I do not know if this is the correct workaround, but, using this way, solved the problem for me.
        Since in Liferay we can configure the portlets to redirect to view after an action request, and, differently from a standard web application, the page is generated during the response phase, when a component have some validation error in a form, the CheckGroups that are part of this form loose it's values.

        This is due to the fact that Check component, in it's onComponentTag() method, uses getInputAsArray(), which get the request parameters. However, during the render phase, the request parameters are lost when the portlet redirects to view after processing an action.

        This problem manifests also when using an FileUploadField in the form, independently of the redirect-after-post configuration.

        To workaround, I changed the onComponentTag of the Check component to use CheckGroup's getRawInput() instead of getInputAsArray, since the rawInput is also serialized with the component:

        if (group.hasRawInput())
        {
        String[] input;
        if (group.getRawInput() != null)
        input = group.getRawInput().split(FormComponent.VALUE_SEPARATOR);
        else
        input = new String[0];

        I do not know if this is the correct workaround, but, using this way, solved the problem for me.
        Robson Miranda made changes -
        Attachment checkgroup-portlet.zip [ 12497245 ]
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Martin Grigorov made changes -
        Component/s wicket-portlet [ 12311803 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Robson Miranda
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development