Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.1.2
    • Component/s: General
    • Labels:
      None
    • Environment:
      XP, IE, jboss-4.0.2

      Description

      I got the validation error today by trying to do the 'smart thing'. Basically i have the list of objects and display as the combo box. What i do before work very fine because all thing is string. This time i try to populate directly my objects to the combo box by specify the converter. The result is OK, i got what i want but when i submit the form i got the Validation error. The code simple like this:

      <h:selectOneMenu id="S1" value = "#

      {csCardRequestHandler.suffixesModel[0].selectedValue}

      "
      disabled="#

      {csCardRequestHandler.suffixesModel[0].disableSelect}

      ">
      <f:selectItems value="#

      {csCardRequestHandler.suffixesModel[0].availableItems}

      "/>
      <f:converter converterId="com.ps.cardservices.SuffixFieldConverter"/>
      <!-f:validator validatorId="com.ps.cardservices.NullValidator"/->
      </h:selectOneMenu>

      Then i thought because of my custom converter so i try to specify the NullValidator just do nothing, still it keeps saying 'ValidatorError'

      One more thing i love to report, on my converter method:
      public String getAsString(FacesContext context, UIComponent component, Object object) throws ConverterException;
      While some tim i get the object as java.lang.String instead of my object type?

      Regards,
      hovan.

        Issue Links

          Activity

          Hide
          Thomas A. Valletta added a comment -

          So I have tracked this same issue. The converter is getting a java.lang.String instead of the expected object after a page is submitted. This seems to be occurring because the HtmlRendererUtils.decodeUISelectOne() sets the submitted value to the value of paramMap.get(clientId). Code from MyFaces 1.1:

          ...
          Map paramMap = facesContext.getExternalContext()
          .getRequestParameterMap();
          String clientId = component.getClientId(facesContext);
          if (paramMap.containsKey(clientId))

          { //request parameter found, set submitted value ((EditableValueHolder) component).setSubmittedValue(paramMap .get(clientId)); }

          else {
          ...

          but then if you step through the encodeEnd:

          HtmlSelectOneMenu(UIComponentBase).encodeEnd(FacesContext) line: 331
          HtmlMenuRenderer(HtmlMenuRendererBase).encodeEnd(FacesContext, UIComponent) line: 54
          HtmlRendererUtils.renderMenu(FacesContext, UISelectOne, boolean) line: 251
          HtmlRendererUtils.internalRenderSelect(FacesContext, UIComponent, boolean, int, boolean) line: 295
          HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(boolean, UIComponent, FacesContext, Converter) line: 327

          you find this code in the HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet that calls the getConvertedStringValue on the lookup which is set to the same submitted value.

          ...
          UISelectOne uiSelectOne = (UISelectOne) uiComponent;
          Object lookup = uiSelectOne.getSubmittedValue();
          if (lookup == null)

          { lookup = uiSelectOne.getValue(); }

          if(RendererUtils.NOTHING.equals(lookup))

          { lookupSet = Collections.EMPTY_SET; }

          else

          { String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter, lookup); lookupSet = Collections.singleton(lookupString); }

          ...

          So the getConvertedStringValue calls the converter and passes in the string from the paramMap. This will probably cause any number of errors in your converter.

          Tom

          Show
          Thomas A. Valletta added a comment - So I have tracked this same issue. The converter is getting a java.lang.String instead of the expected object after a page is submitted. This seems to be occurring because the HtmlRendererUtils.decodeUISelectOne() sets the submitted value to the value of paramMap.get(clientId). Code from MyFaces 1.1: ... Map paramMap = facesContext.getExternalContext() .getRequestParameterMap(); String clientId = component.getClientId(facesContext); if (paramMap.containsKey(clientId)) { //request parameter found, set submitted value ((EditableValueHolder) component).setSubmittedValue(paramMap .get(clientId)); } else { ... but then if you step through the encodeEnd: HtmlSelectOneMenu(UIComponentBase).encodeEnd(FacesContext) line: 331 HtmlMenuRenderer(HtmlMenuRendererBase).encodeEnd(FacesContext, UIComponent) line: 54 HtmlRendererUtils.renderMenu(FacesContext, UISelectOne, boolean) line: 251 HtmlRendererUtils.internalRenderSelect(FacesContext, UIComponent, boolean, int, boolean) line: 295 HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(boolean, UIComponent, FacesContext, Converter) line: 327 you find this code in the HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet that calls the getConvertedStringValue on the lookup which is set to the same submitted value. ... UISelectOne uiSelectOne = (UISelectOne) uiComponent; Object lookup = uiSelectOne.getSubmittedValue(); if (lookup == null) { lookup = uiSelectOne.getValue(); } if(RendererUtils.NOTHING.equals(lookup)) { lookupSet = Collections.EMPTY_SET; } else { String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter, lookup); lookupSet = Collections.singleton(lookupString); } ... So the getConvertedStringValue calls the converter and passes in the string from the paramMap. This will probably cause any number of errors in your converter. Tom
          Hide
          hovan added a comment -

          Thanks for the comment, first i got the class cast exception which is the object in method
          public String getAsString(FacesContext context, UIComponent component, Object object) throws ConverterException;
          is the java.lang.String instead of my class. I was a little suprise.

          Then i did take a look at all the converters implements by MyFaces team, what i learn is they check the String type all the time before do the cast. I really don't know why (i love to hear some explainations), because i thought it's must always my class.

          I get over the class cast problem, i got the Validation Error. The funny thing is all of Combox i did before version 0.9 it works find if i specify the f:numberConverter, but now with version 1.0 i got the same error ValidationError. What i did in this case is remove the f:numberConverter and i works.

          So you right, there a huge bug in this implement. I hope to get the fix soon, cause this is the big project we convert from struts, and very much depends on MyFaces

          Hovan.

          Show
          hovan added a comment - Thanks for the comment, first i got the class cast exception which is the object in method public String getAsString(FacesContext context, UIComponent component, Object object) throws ConverterException; is the java.lang.String instead of my class. I was a little suprise. Then i did take a look at all the converters implements by MyFaces team, what i learn is they check the String type all the time before do the cast. I really don't know why (i love to hear some explainations), because i thought it's must always my class. I get over the class cast problem, i got the Validation Error. The funny thing is all of Combox i did before version 0.9 it works find if i specify the f:numberConverter, but now with version 1.0 i got the same error ValidationError. What i did in this case is remove the f:numberConverter and i works. So you right, there a huge bug in this implement. I hope to get the fix soon, cause this is the big project we convert from struts, and very much depends on MyFaces Hovan.
          Hide
          Bruno Aranda added a comment -

          This should be fixed in the current SVN now and available in the next nightly. Please check that everything is working ok for you,

          Show
          Bruno Aranda added a comment - This should be fixed in the current SVN now and available in the next nightly. Please check that everything is working ok for you,

            People

            • Assignee:
              Bruno Aranda
              Reporter:
              hovan
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development