You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Newton <ne...@yahoo.com> on 2008/06/13 17:06:02 UTC

[OT] Re: struts2: how to read the 'potenrial list' from a database

No CC. Just list. I don't need two copies of all list traffic.


--- On Fri, 6/13/08, Onur Idrisoglu <on...@gmail.com> wrote:

> From: Onur Idrisoglu <on...@gmail.com>
> Subject: Re: struts2: how to read the 'potenrial list' from a database
> To: "Struts Users Mailing List" <us...@struts.apache.org>, newton.dave@yahoo.com
> Date: Friday, June 13, 2008, 10:09 AM
> I'm not sure if you can do that with autocompleter..
> Autocompleter need the whole list at startup, but as I
> understand you want
> to shape this list dynamically according to what user
> types. Each time user
> types a character, the action will create a new list...
> 
> Maybe you can use DWR to do this
> 
> On Fri, Jun 13, 2008 at 3:13 PM, Dave Newton
> <ne...@yahoo.com> wrote:
> 
> > --- On Fri, 6/13/08, srichin
> <sr...@infosys.com> wrote:
> > > I want the objects id to be the value of the
> option and
> > > code to bethe label to be shown in the
> autocompleter dropdown options.
> > >
> > > I should be shown codes as select options in the
> dropdown and when I
> > > select any of the code, the corresponding id
> should go as the
> > > value that has been selected
> > >
> > > Pointers on this would be of great help
> >
> > I understand what you're trying to do, I don't
> understand what specific
> > aspect you're having a problem with. You said you
> implemented the action
> > with a hard-coded list. An action that uses a database
> instead is almost
> > exactly the same, but it accesses a database instead
> of using a hard-coded
> > list.
> >
> > The Struts 2.0 autocompleter docs [1] summarize the
> usage of the tag; the
> > action will be called with the current value in the
> text box. You use that
> > partial value to do a database search (or filter an
> existing list, or
> > however you'll implement that part).
> >
> > Dave
> >
> > [1]
> >
> http://struts.apache.org/2.0.11/docs/ajax-tags.html#AjaxTags-autocompleterTag
> >
> > > newton.dave wrote:
> > > >
> > > > Search a database of city names?
> > > >
> > > > I'm not sure what you're asking.
> > > >
> > > > --- On Thu, 6/12/08, xianwinwin
> > > <xi...@gmail.com> wrote:
> > >>> I have a list of 20,000 cities; I would
> like the
> > >>> user to provide at least 2 chars and then
> present him a'potential
> > > list'.
> > > >>
> > > >> I managed to do this:
> > > >>
> > > >> JSP
> > > >>
> > > >> <s:autocompleter
> theme="simple"
> > > >> list="state"
> > > name="StateName"/>
> > > >>
> > > >>
> > > >>
> > > >> Java:
> > > >>
> > > >> public class autocompleter extends
> ActionSupport
> > > >> {
> > > >>   private List state;
> > > >>   public String execute() throws
> Exception{
> > > >>     state = new ArrayList();
> > > >>     state.add("Bonn");
> > > >>     state.add("Paris");
> > > >> .
> > > >> .
> > > >> .
> > > >>
> > > >>     return SUCCESS;
> > > >>   }
> > > >>
> > > >>    public List getState(){
> > > >>     return state;
> > > >>   }
> > > >> }
> > > >>
> > > >> as you can see, the autocompliter is
> based on the
> > > >> 'state' I initially
> > > >> provided. But what if the list is
> huge???
> > > >>
> > > >> Q: How can I invoke an action once the
> user types
> > > a letter
> > > >> (str) and the
> > > >> string gets to the invoked-method (based
> on the
> > > str the
> > > >> method will invoke
> > > >> the appropriate list)
> > > >>
> > > >> thank you!!!
> > > >> --
> > > >> View this message in context:
> > > >>
> > >
> >
> http://www.nabble.com/struts2%3A-how-to-read-the-%27potenrial-list%27-from-a-database-tp17810726p17810726.html
> > > >> Sent from the Struts - User mailing list
> archive
> > > at
> > > >> Nabble.com.
> > > >>
> > > >>
> > > >>
> > >
> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail:
> > > user-unsubscribe@struts.apache.org
> > > >> For additional commands, e-mail:
> > > >> user-help@struts.apache.org
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail:
> > > user-help@struts.apache.org
> > > >
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://www.nabble.com/struts2%3A-autocompleter---howto-read-the-%27potenrial-list%27-from-a-database-tp17810726p17820863.html
> > > Sent from the Struts - User mailing list archive
> at
> > > Nabble.com.
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> > > user-help@struts.apache.org
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> 
> 
> -- 
> -- --
> Onur Idrisoglu

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: struts2: how to read the 'potenrial list' from a database

Posted by xianwinwin <xi...@gmail.com>.
OK...I'm getting there! I got the idea: loadOnTextChange.

so I ended up with this JSP:

<s:url id="json" value="/groupManagement_potentialList.do" />
<s:autocompleter  href="%{json}" loadOnTextChange="true"
loadMinimumCount="1"   showDownArrow="true" name="userKeys" theme="ajax"
autoComplete="true"/>

BUT where is the list?!?!?!
I can invoke a method, but how does the statement above knows which list to
use?! 
And what should the potentialList method return?

THANKS for any pointers!




newton.dave wrote:
> 
> No CC. Just list. I don't need two copies of all list traffic.
> 
> 
> --- On Fri, 6/13/08, Onur Idrisoglu <on...@gmail.com> wrote:
> 
>> From: Onur Idrisoglu <on...@gmail.com>
>> Subject: Re: struts2: how to read the 'potenrial list' from a database
>> To: "Struts Users Mailing List" <us...@struts.apache.org>,
>> newton.dave@yahoo.com
>> Date: Friday, June 13, 2008, 10:09 AM
>> I'm not sure if you can do that with autocompleter..
>> Autocompleter need the whole list at startup, but as I
>> understand you want
>> to shape this list dynamically according to what user
>> types. Each time user
>> types a character, the action will create a new list...
>> 
>> Maybe you can use DWR to do this
>> 
>> On Fri, Jun 13, 2008 at 3:13 PM, Dave Newton
>> <ne...@yahoo.com> wrote:
>> 
>> > --- On Fri, 6/13/08, srichin
>> <sr...@infosys.com> wrote:
>> > > I want the objects id to be the value of the
>> option and
>> > > code to bethe label to be shown in the
>> autocompleter dropdown options.
>> > >
>> > > I should be shown codes as select options in the
>> dropdown and when I
>> > > select any of the code, the corresponding id
>> should go as the
>> > > value that has been selected
>> > >
>> > > Pointers on this would be of great help
>> >
>> > I understand what you're trying to do, I don't
>> understand what specific
>> > aspect you're having a problem with. You said you
>> implemented the action
>> > with a hard-coded list. An action that uses a database
>> instead is almost
>> > exactly the same, but it accesses a database instead
>> of using a hard-coded
>> > list.
>> >
>> > The Struts 2.0 autocompleter docs [1] summarize the
>> usage of the tag; the
>> > action will be called with the current value in the
>> text box. You use that
>> > partial value to do a database search (or filter an
>> existing list, or
>> > however you'll implement that part).
>> >
>> > Dave
>> >
>> > [1]
>> >
>> http://struts.apache.org/2.0.11/docs/ajax-tags.html#AjaxTags-autocompleterTag
>> >
>> > > newton.dave wrote:
>> > > >
>> > > > Search a database of city names?
>> > > >
>> > > > I'm not sure what you're asking.
>> > > >
>> > > > --- On Thu, 6/12/08, xianwinwin
>> > > <xi...@gmail.com> wrote:
>> > >>> I have a list of 20,000 cities; I would
>> like the
>> > >>> user to provide at least 2 chars and then
>> present him a'potential
>> > > list'.
>> > > >>
>> > > >> I managed to do this:
>> > > >>
>> > > >> JSP
>> > > >>
>> > > >> <s:autocompleter
>> theme="simple"
>> > > >> list="state"
>> > > name="StateName"/>
>> > > >>
>> > > >>
>> > > >>
>> > > >> Java:
>> > > >>
>> > > >> public class autocompleter extends
>> ActionSupport
>> > > >> {
>> > > >>   private List state;
>> > > >>   public String execute() throws
>> Exception{
>> > > >>     state = new ArrayList();
>> > > >>     state.add("Bonn");
>> > > >>     state.add("Paris");
>> > > >> .
>> > > >> .
>> > > >> .
>> > > >>
>> > > >>     return SUCCESS;
>> > > >>   }
>> > > >>
>> > > >>    public List getState(){
>> > > >>     return state;
>> > > >>   }
>> > > >> }
>> > > >>
>> > > >> as you can see, the autocompliter is
>> based on the
>> > > >> 'state' I initially
>> > > >> provided. But what if the list is
>> huge???
>> > > >>
>> > > >> Q: How can I invoke an action once the
>> user types
>> > > a letter
>> > > >> (str) and the
>> > > >> string gets to the invoked-method (based
>> on the
>> > > str the
>> > > >> method will invoke
>> > > >> the appropriate list)
>> > > >>
>> > > >> thank you!!!
>> > > >> --
>> > > >> View this message in context:
>> > > >>
>> > >
>> >
>> http://www.nabble.com/struts2%3A-how-to-read-the-%27potenrial-list%27-from-a-database-tp17810726p17810726.html
>> > > >> Sent from the Struts - User mailing list
>> archive
>> > > at
>> > > >> Nabble.com.
>> > > >>
>> > > >>
>> > > >>
>> > >
>> ---------------------------------------------------------------------
>> > > >> To unsubscribe, e-mail:
>> > > user-unsubscribe@struts.apache.org
>> > > >> For additional commands, e-mail:
>> > > >> user-help@struts.apache.org
>> > > >
>> > > >
>> > >
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail:
>> > > user-unsubscribe@struts.apache.org
>> > > > For additional commands, e-mail:
>> > > user-help@struts.apache.org
>> > > >
>> > > >
>> > > >
>> > >
>> > > --
>> > > View this message in context:
>> > >
>> >
>> http://www.nabble.com/struts2%3A-autocompleter---howto-read-the-%27potenrial-list%27-from-a-database-tp17810726p17820863.html
>> > > Sent from the Struts - User mailing list archive
>> at
>> > > Nabble.com.
>> > >
>> > >
>> > >
>> ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail:
>> user-unsubscribe@struts.apache.org
>> > > For additional commands, e-mail:
>> > > user-help@struts.apache.org
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail:
>> user-help@struts.apache.org
>> >
>> >
>> 
>> 
>> -- 
>> -- --
>> Onur Idrisoglu
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/struts2%3A-autocompleter---howto-read-the-%27potenrial-list%27-from-a-database-tp17810726p17828178.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org