myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerald Müllan" <gmuel...@apache.org>
Subject Re: s:inputSuggestAjax - how this tag works with database values
Date Tue, 03 Jul 2007 07:31:56 GMT
You have to filter out the AssetMgmtSystem elements for the right
ones, which begin with A or B.

You can do this in the Hibernate query directly (better one) or in the
iteration afterwards.

cheers,

Gerald

On 7/2/07, bansi <mail2bansi@yahoo.com> wrote:
>
> Hi Gerald
> As suggested i wrote the code below for autoComplete to display suggested
> items  based on user input. For example if user keys in  "A" or "B" into the
> textbox, then  suggested items starting with either A or B only should be
> displayed.
>
> public List autocomplete(String suggest) {
>     String pref = suggest;
>     ArrayList result = new ArrayList();
>
>     Iterator iterator = getAssetList().iterator(); // getAssetList()
> retrives Asset List from database
>     while (iterator.hasNext()) {
>         AssetMgmtSystem elem = (AssetMgmtSystem) iterator.next();
>         if ((elem != null &&
> elem.getName().toLowerCase().indexOf(pref.toLowerCase()) == 0) ||
> "".equals(pref))
>         {
>             result.add(elem);
>         }
>     }
>     return result;
> }
>
> It still displays incorrectly suggested items. Any pointers/suggestions will
> be highly appreciated
>
>
>
> Gerald Müllan wrote:
> >
> > Hi,
> >
> > the expected behaviour should be completely done in the
> > suggestedItemsMethod. So it is
> > the developers responsibility to return the list from the db-call, in
> > your case getAssetMgmtSystems(). The call to well fitting suggestions
> > must occur there.
> >
> > cheers,
> >
> > Gerald
> >
> > On 7/2/07, bansi <mail2bansi@yahoo.com> wrote:
> >>
> >> I am using Facelets 1.1.2 Tomahawk Sandbox 1.1.5 . The s:inputSuggestAjax
> >> component example as mentioned in MyFaces wiki works perfectly fine for
> >> me.
> >> When i tried using it against the values retrieved from Database, it
> >> appends
> >> the prefix to the values from database.
> >>
> >> For example if i key in "A" in the textbox , then suggested words shows
> >> all
> >> the database values appended with A .
> >>
> >>
> >>
> >> i.e. AWashington
> >>
> >>       ANewYork
> >>
> >>       ANew Jersey
> >>
> >>
> >>
> >> The expected behaviour is it should only those values from Database which
> >> starts with A or starts with any character that is keyed into textbox
> >>
> >>
> >>
> >> Here is the snippet
> >>
> >> JSF page:
> >>
> >> <h:outputText value="Enter your state : "/>
> >>
> >>
> >> <s:inputSuggestAjax suggestedItemsMethod="#{test.getSuggestedWords}"
> >> value="#{test.currentValue}" />
> >>
> >>
> >>
> >> Backing Bean:
> >>
> >> public List doGetStateList(String keyword){
> >>
> >>
> >>
> >> List stateList = new ArrayList();
> >>
> >> List<AssetMgmtSystem> assetMgmtSystem = new ArrayList<AssetMgmtSystem>();
> >>
> >> assetMgmtSystem = deviceManager.getAssetMgmtSystems(); // calls database
> >> to
> >> retrieve  state List
> >>
> >>
> >>
> >> for (int i=0; i< assetMgmtSystem.size(); i++) {
> >>
> >> AssetMgmtSystem asset = (AssetMgmtSystem) assetMgmtSystem.get(i);
> >>
> >> Long assetId = asset.getId();
> >>
> >> String assetName = asset.getName();
> >>
> >> keyword = assetName.substring(0,1);
> >>
> >> stateList.add(keyword + assetName);
> >>
> >> }
> >>
> >> return stateList;
> >>
> >>
> >>
> >> }
> >>
> >>
> >>
> >> Any pointers/suggestions will be highly appreciated
> >>
> >>
> >>
> >> Regards
> >>
> >> Bansi
> >>
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/s%3AinputSuggestAjax---how-this-tag-works-with-database-values-tf4009641.html#a11387032
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
>
> --
> View this message in context: http://www.nabble.com/s%3AinputSuggestAjax---how-this-tag-works-with-database-values-tf4009641.html#a11397388
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Mime
View raw message