Under the hood, tapestry is using the Ajax.Autocompleter from Scriptaculous (at 
least for now). One of the parameters to the javascript is "parameters" (see: 
http://script.aculo.us/docs/Ajax.Autocompleter.html). Tapestry doesn't allow 
you set this by default, BUT, you could extend the autocomplete mixin and 
override the "configure" method (the superclass implementation is empty) to add 
the value to the configuration.

Then in your custom "configure" method, you could add whatever you wanted. For 
instance, you could do something like pass the current generic attribute, or 
generic attribute name, or whatever you need, as a parameter. Then in your 
"onProvideCompletions" method, you can grab the parameter from an injected 
Request object.

Robert

On Aug 13, 2012, at 8/136:13 PM , William Lopes wrote:

> If someone to have some other idea that can to solve, I'm ready to listen.
> 
> Thanks.
> 
> 2012/8/13 William Lopes <williamlopes....@gmail.com>
> 
>> Hi guys.
>> 
>> I'm already for done my project, but now the things are too ugly.
>> 
>> So, I need make an autocomplete, the default I already did, but don't work
>> of the way that I need.
>> 
>> I have a form dynamic, so all my fields are dynamics, with it I can't use
>> the default autocomplete, because it don't distinguish which field is and
>> so I can't prepare the autocomplete correctly.
>> 
>> My .tml:
>> 
>>> <t:form t:type="form" t:id="AtualizarForm">
>>> <t:errors t:banner="${message:default-banner}"/>
>>> <table id="usuarioFormTable">
>>> <tr>
>>> <t:loop source="listAtributoGeneric" value="currentAtributoGeneric"
>>> encoder="encoder">
>>> <t:submitNotifier>
>>> <tr>
>>> <td align="right">${currentAtributoGeneric.name}:</td>
>>> <td width="10"/>
>>> <td align="left">
>>> <t:delegate to="activeBlock"/>
>>> </td>
>>> </tr>
>>> </t:submitNotifier>
>>> </t:loop>
>>> </tr>
>>> </table>
>>> 
>>> <table>
>>> <tr><td colspan="3" align="center">
>>> <br />
>>> <input type="submit" t:type="submit" t:id="salvaButton"
>>> value="${message:salvar-label}" class="buttonSubmit" />
>>> </td></tr>
>>> </table>
>>> 
>>> </t:form>
>>> 
>>> <t:block id="stringBlock">
>>> <t:textfield value="currentAtributoGeneric.value"
>>> label="${currentAtributoGeneric.name}" translate="string"
>>> validate="maxLength=255" t:id="stringGeneric" size="50"/>
>>> </t:block>
>>> <t:block id="stringLargeBlock">
>>> <t:textarea value="currentAtributoGeneric.value"
>>> label="${currentAtributoGeneric.name}" translate="string"
>>> validate="maxLength=2048" t:id="stringLargeGeneric" rows="3" cols="49"/>
>>> </t:block>
>>> <t:block id="dateBlock">
>>> <t:datefield value="currentAtributoGeneric.value" format="dd/MM/yyyy"
>>> label="${currentAtributoGeneric.name}"
>>> validate="maxLength=10,regexp" t:id="dateGeneric"
>>> onkeypress="javascript:formataData(this.value, this.id, event);"
>>> size="12" />
>>> </t:block>
>>> <t:block id="numericBlock">
>>> <t:textfield value="currentAtributoGeneric.value"
>>> label="${currentAtributoGeneric.name}" translate="string"
>>> validate="maxLength=20,regexp" t:id="numericGeneric" size="20"/>
>>> </t:block>
>>> <t:block id="numericDecimalBlock">
>>> <t:textfield value="valorDecimal" label="${currentAtributoGeneric.name}"
>>> translate="string"
>>> validate="maxLength=18,regexp" t:id="numericDecimalGeneric"
>>> onkeypress="javascript:formataDecimal(this, 17, event, 2)" size="20"/>
>>> </t:block>
>>> <t:block id="modeloDadosBlock">
>>> <t:textfield value="currentAtributoGeneric.value"
>>> label="${currentAtributoGeneric.name}" translate="string"
>>> validate="maxLength=50" t:id="modeloDadosGeneric"
>>> t:mixins="Autocomplete" size="50"/>
>>> </t:block>
>> 
>> 
>> 
>> .java:
>> 
>>> List<String> onProvideCompletionsFromModeloDadosGeneric(String partial) {
>> 
>> List<Material> matches = null;
>> 
>> try {
>> 
>> matches = service.getAllByFiltroTextoAndModeloDados(partial,
>>> modeloDados);
>> 
>> } catch (Exception e) {
>> 
>> System.out.println("Erro em " + this);
>> 
>> e.printStackTrace();
>> 
>> }
>> 
>> 
>>> List<String> result = new ArrayList<String>();
>> 
>> 
>>> for (Material i : matches) {
>> 
>> for(ValorAtributo j : i.getValoresAtributo()) {
>> 
>> if((j.getAtributo().getTipoAtributo() == TipoAtributo.TEXTO_GRANDE
>> 
>> || j.getAtributo().getTipoAtributo() == TipoAtributo.TEXTO_PEQUENO)
>> 
>> && j.getValor().toLowerCase().contains(partial.toLowerCase())) {
>> 
>> result.add(i.getId() + " - " + j.getValor());
>> 
>> break;
>> 
>> }
>> 
>> }
>> 
>> }
>> 
>> 
>>> return result;
>> 
>> }
>> 
>> 
>> How you can see, in *matches =
>> service.getAllByFiltroTextoAndModeloDados(partial, modeloDados);* , I
>> need of a parameter for can define which modeloDados is.
>> 
>> How I could do it? (following the default of the Tapestry)
>> 
>> Thanks!
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to