Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12353

Incorrect documentation/taglib on <a4j:param>

    Details

    • Sprint:
      4.3.0.M2 sprint 1
    • Story Points:
      0.25
    • Affects:
      Documentation (Ref Guide, User Guide, etc.)
    • Workaround Description:
      Hide

      Use "half-documented" "converter" attribute of <a4j:param>.

      Show
      Use "half-documented" "converter" attribute of <a4j:param>.

      Description

      Technical background (RichFaces developers can easy skip it):


      <a4j:param> performs setting of its value into an expression specified in "assignTo" attribute. As this component is set as Action listener for ActionSource parent - org.richfaces.component.AbstractParameter.processAction(ActionEvent) is called. This method directly retrieves request parameter with this parameter's name/clientId:
      String requestValue = context.getExternalContext().getRequestParameterMap().get(getName());

      and then, if converter's not found, sets it as a value of an expression, specified in "assignTo":

      if (requestValue != null) {
        Class<?> type = updateBinding.getType(elContext);
        Converter converter = createConverter(context, type);
        ...
      }
      
      if (null != convertedValue) {
       updateBinding.setValue(elContext, convertedValue);
      }
      

      When our expression value has reifiable type, for which JSF (or app developer) has registered a converter (for instance - Boolean) - all's peachy keen. But when developer uses, e.g., Map - expression's type (got in updateBinding.getType(ELContext)) is Object, and we're starting to receive strings in Map, which is probably parameterized with anything. Also this situation applies to "non-standard" reference types (user-declared JavaBean, for instance).

      org.richfaces.view.facelets.html.ParameterHandler:
      
      org.richfaces.view.facelets.html.ParameterHandler.ActionParamMetaRule.applyRule(String, TagAttribute, MetadataTarget):
      ...
      else if ("converter".equals(name)) {
                          if (attribute.isLiteral()) {
                              return new LiteralConverterMetadata(attribute.getValue());
                          } else {
                              return new DynamicConverterMetadata(attribute);
                          }
                      }
      ...
      

      I.e. <a4j:param> tag handler designed to accept "converter" attribute, which can appropriately convert value, passed from client.


      a4j:param VDL Doc has no mention of it, and value/assignTo attributes type specified as "java.lang.Object". a4j.taglib.xml has no mention of it, so developers have no chance to discover it, e.g., through the content assist, Rich Component Reference has only two sentences about it, which are very easy to miss.
      Also, RichFaces Showcase contains no example, which uses "converter" attribute.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                bleathem Brian Leathem
                Reporter:
                a.kiselyov Alexander Kiselyov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: