Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-1000

Make the raw entered value available

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.1.7-SNAPSHOT
    • None
    • InputSuggestAjax
    • None

    Description

      It is very handy to allow users to type any text. If the value is then not selected from the sugggestList it would be nice to be able to use the raw entered value. this can be done by adding setRawValueMethod to the parameters in the JSf or Facelets file.

      I am using this:
      ==================
      <s:inputSuggestAjax
      suggestedItemsMethod="#

      {productSearch.getSuggestItems}

      "
      maxSuggestedItems="50"
      binding="#

      {invoiceManager.selectedProduct}

      "
      rawValueMethod="#

      {invoiceManager.setRawValue}

      "
      itemLabelMethod="#

      {productSearch.getItemLabel}

      "
      charset="utf-8"
      id="tabClientsInvoices_SelectedProductId"
      forceId="true"
      autoComplete="false"
      styleClass="searchfield"
      style=""
      disabled="#

      {!invoiceManager.mode.editOrAdd}

      "
      converter="ProductSearchConverter"
      />
      ==================

      I changed InputSuggestAjaxRenderer.java to contain the following method:
      ==================
      /**

      • Memorize raw input value, for later use through tag binding
        */
        //@Override
        public Collection getSuggestedItems(FacesContext context, UIComponent uiComponent) {
        String rawValue = (String) AjaxDecodePhaseListener.getValueForComponent(context, uiComponent);

      LOGGER.debug("getSuggestedItems - rawValue: "+rawValue);
      MethodBinding mb = ((InputSuggestAjax) uiComponent).getRawValueMethod();
      if(mb != null) {
      mb.invoke(context, new Object[]

      {rawValue}

      );
      }

      return super.getSuggestedItems(context, uiComponent);
      }
      }
      ==================
      And obviosly
      InputSuggestAjax.java to contain the getter and setter for this parameter:
      ==================
      public MethodBinding getRawValueMethod()

      { return _rawValueMethod; }

      public void setRawValueMethod(MethodBinding valueMethod)

      { _rawValueMethod = valueMethod; }

      ==================

      MAG,
      Milo

      Attachments

        Activity

          People

            Unassigned Unassigned
            milovdzee Milo van der Zee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: