Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2846

s:url Tag with parameters does not work or results in ClassCastException



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s:
    • Fix Version/s: 2.1.3
    • Labels:
    • Environment:

      Pluto 1.1.6, Java5


      Using Example 1 from s:url Tag


      does not work in an PortletEnvironment. Only the url is generated.
      Debugging to PortletUrlHelper the params map is empty.

      <s:url value="editGadget.action">
      <s:param name="id" value="%


      " />

      does not work. The params map is empty

      <s:url value="editGadget.action">
      <s:param name="id" value="abc" />

      does not work. The params map is empty.

      <s:url value="editGadget.action">
      <s:param name="id" value="40" />

      does not work. The param is in the Map, but its not a String, its an Integer - which results in a ClassCastException at:

      String key = (String)it.next();
      String val = (String)params.get(key);

      Portlet Spec mentions to use Servlet for resource streaming and other things you can't do with portlets.
      I need to generate servlet URLs containing parameters - but it seems i can't create them with struts.

      Using "includeParams=ALL" (which you may use to get extraparams included), does result in

      [Ljava.lang.String; cannot be cast to java.lang.String

      because PortletUrlHelper gots a method called: ensureParamsAreStringArrays which is called when constructing the surrounding form ...

      which does convert the entire map to hold string arrays - but than buildResourceUrl must fail everytime.

      Using get and %


      it does work nearly, only the CCE is making things worse.
      The fault is

      Object value = findValue(this.value);
      component.addParameter(name, value);

      in the param Tag. findValue does return actually an Integer instance which is put to the parameter Map.
      This should be converted to String before inserting it to the map.

      Besides this, using All the above things still apply.


        1. Param.diff
          0.7 kB
          Torsten Krah
        2. PortletUrlHelper.diff
          5 kB
          Torsten Krah



            • Assignee:
              nilsga Nils-Helge Garli
              tkrah Torsten Krah
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: