Make the raw entered value available
------------------------------------

                 Key: TOMAHAWK-1000
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1000
             Project: MyFaces Tomahawk
          Issue Type: New Feature
          Components: InputSuggestAjax
    Affects Versions: 1.1.6-SNAPSHOT
            Reporter: Milo van der Zee


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

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to