You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Pedro Viegas <vi...@gmail.com> on 2007/02/07 04:00:55 UTC

T4.1.1: Autocomplete is generating tow components instead of one!

I there.
I have a strange behaviour with the T4.1.1 Autocompleter.
I have build a wrapper component that encapsulates the Autocompleter with a
few added funcionalities for my apps use.
Basically the new component just wraps a autocompleter inside and set a few
things like the ListModel from a few new parameters it receives.
Something like this...

InputAutocomplete.html

<html>
<body jwcid="$content$">
<span class="autocompleter" jwcid="autoCompleter"
    style="ognl:'width: '+width+'px; height: 20px;'" />
</body>
</html>

InputAutocomple.jwc (the relevant parts...)

<?xml version="1.0"?>
<!DOCTYPE component-specification...Tapestry_4_0.dtd">
<component-specification class="
com.teamware.fw.view.components.forms.InputAutocomplete" allow-body="no"
    allow-informal-parameters="yes">
    <description>Input field for LOV value selection based on
Autocompleter</description>
(...)
    <parameter name="service">
        <description>BaseService instance to get data list
from</description>
    </parameter>

    <parameter name="fieldName">
        <description>Name of the data field to list in the drop down
autocompleter list</description>
    </parameter>

    <parameter name="keyName" default-value="literal:id">
        <description>Name of the key field of the model</description>
    </parameter>

    <parameter name="listModel" default-value="ognl:defaultModel">
        <description>
            The IAutocompleteModel that should be used to filter the drop
down list and render the drop down list
        </description>
    </parameter>
(...)
</component-specification>

InputAutocomplete.java

public abstract class InputAutocomplete extends BaseComponentImplementation
        implements IFormComponent {

    public abstract BaseService getService();
    public abstract String getFieldName();
    public abstract String getKeyName();

    // TODO: public abstract LinkedFormComponents getFilterComponent();
    // TODO: public abstract String getFilterFieldAttribute();

    public abstract BasePojo getValue();

    @Component(id = "autoCompleter", type = "Autocompleter", bindings = {
            "displayName=displayName", "value=value", "model=listModel",
            "filterOnChange=true", "validators=validators" })
    public abstract Autocompleter getAutoCompleter();

    public IAutocompleteModel getDefaultModel() {
        getLogger().debug("Component: " + this.toString());

        return new DefaultAutocompleteModel(getService().getAll(),
                getKeyName(), getFieldName());
    }
}

The BaseComponentImplementation is not relevant since it only provides
common resources for all my componentes like loging and stuff.
This component when used generates a curious result...

In the surrounding FORM component... 2 autoCompleter's

<input type="hidden" name="formids" value="autoCompleter,autoCompleter_0..."/>


The generated INPUTs is only one... but the second, notice the "_0" suffix!

<select name="autoCompleter_0" id="autoCompleter_0"
class="autocompleter" style="width: 300px; height: 20px;"></select>


And in the configuring JS in the bottom...

        var autoCompleterprop={"dataUrl":"/delegateit/app?component=departmentSearch.autoCompleter&json=true&page=Home&service=direct&updateParts=autoCompleter&filter=%{searchString}","mode":"remote","widgetId":"autoCompleter","name":"autoCompleter","searchDelay":100,"fadeTime":200};
        tapestry.widget.synchronizeWidgetState("autoCompleter",
"Select", autoCompleterprop);
        if (autoCompleterprop["label"] && autoCompleterprop["value"]){
            var selw=dojo.widget.byId("autoCompleter");
            selw.setValue(autoCompleterprop["value"]);
            selw.setLabel(autoCompleterprop["label"]);
        }


        var autoCompleter_0prop={"dataUrl":"/delegateit/app?component=departmentSearch.autoCompleter&json=true&page=Home&service=direct&updateParts=autoCompleter&filter=%{searchString}","mode":"remote","widgetId":"autoCompleter_0","name":"autoCompleter_0","searchDelay":100,"fadeTime":200};
        tapestry.widget.synchronizeWidgetState("autoCompleter_0",
"Select", autoCompleter_0prop);
        if (autoCompleter_0prop["label"] && autoCompleter_0prop["value"]){
            var selw=dojo.widget.byId("autoCompleter_0");
            selw.setValue(autoCompleter_0prop["value"]);
            selw.setLabel(autoCompleter_0prop["label"]);
        }

Just to sum it up... the logger debug line IS called twice, so it really is
instanciated twice, even thought the INPUT tag is only generated for the
second one! Strange!
02:49:24,197 DEBUG [InputAutocomplete] Component:
$InputAutocomplete_11@17dea61[Home/departmentSearch]
02:49:24,402 DEBUG [InputAutocomplete] Component:
$InputAutocomplete_11@17dea61[Home/departmentSearch]


Can someone help me please?
This sound like a BUG of the component right? Or I'm making an unsuported
usage of it of some kind.



---
Pedro Viegas