Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: [S2] autocompleter, predefining initial value

Musachy Barroso

2006-12-17

Replies:

Making the autocompleter reload its content while typing was easier than
expected :). Do you think it would be better to have that behavior , or
the current one, by default?

musachy

Dariusz Wojtas wrote:
> Hi,
>
> I am using Struts 2.0.2, trunk.
>
> I have an action (/listy/kodyPocztowe) that returns postal codes [id,
> name]
> and another action that server a form (form points to the same action
> back).
>
> How to define the initial value in the autocompleter field?
> Even if I submit the form and it reloads with the same action, the
> autocompleter does not display previously selected option.
>
> I tried to use a javascript (shown below) to debug it (print field
> names).
> When an alert shows, in place of autocompleter I can see plain
> textfield with resubmitted values (as expected), after alert messages
> do finish it is replaced by the autocompleter widget - empty value,
> nothing selected. the widget is loaded with options, but none is
> selected.
>
> Any hint how to solve this mistery?
> What am I missing?
>
>
> <script type="text/javascript">
> function filterKodPocztowy(field) {
>   alert(field.name);
>   return field.name == "kodPocztowy";
> }
> </script>
>
> <s:form id="calcForm" ...>
>  [...]
>  <s:url id="kodPocztowyURL" value="/listy/kodyPocztowe.action" />
>  <s:autocompleter name="kodPocztowy"
>   theme="ajax"
>   href="%{kodPocztowyURL}"
>   forceValidOption="true"
>   formId="calcForm"
>   formFilter="filterKodPocztowy"
>   />
>  [...]
>
>  <s:submit .../>
> </s:form
>
>
> Dariusz Wojtas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.