sj:select with preselected item ?

67 views
Skip to first unread message

skydiablo

unread,
Apr 1, 2011, 12:21:10 PM4/1/11
to struts2-jquery
hiho...

i have a "<sj:select ... />" tag, all works fine! but now, i want to
preselect a item from the JSON result ? how can i do this ? i have try
it with the "value" attribut, but nothing helps...

greez & thx,
sky...

jogep

unread,
Apr 2, 2011, 2:21:44 PM4/2/11
to struts2-jquery
the value attribute should work.

can you give a sample?

Johannes
---
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep

skydiablo

unread,
Apr 4, 2011, 3:09:25 AM4/4/11
to struts2-jquery
JSP Code:

<s:url id="courseSearchFormCourseFormatSelect"
action="courseSearchFormCourseFormatSelect" namespace="/json" />
<sj:select
href="%{courseSearchFormCourseFormatSelect}"
cssStyle="width : 20em;"
headerValue="%{getText('course.search.header.format')}"
headerKey="-1"
list="groups"
listKey="id"
listValue="name"
name="searchCriteria.group"
onChangeTopics="courseFormatChanged"
indicator="courseSelectsFormatLoading"
value="1"
/>

JSON Response:
{"groups":[{"deleted":false,"id":1,"longName":"A Long
Name","name":"Foo","sorting":null},{"deleted":false,"id":
2,"longName":null,"name":"Bar","sorting":null},{"deleted":false,"id":
3,"longName":null,"name":"Baz","sorting":null}],"localities":null,"searchCriteria":null,"templates":null}

the value is set to "1" or "Foo" for testing. it dosent work ?

struts-jquery-plugin: 2.5.1
jquery: 1.4.4

jogep

unread,
Apr 4, 2011, 3:23:32 AM4/4/11
to struts2-jquery
Please try out the latest version 2.5.3.
It was a bug which sould be solved in this version.

Don't forget to clear your browser cache.
On Apr 4, 9:09 am, skydiablo <hoessli...@nonacom.de> wrote:
> JSP Code:
>
> <s:url id="courseSearchFormCourseFormatSelect"
> action="courseSearchFormCourseFormatSelect" namespace="/json" />
> <sj:select
>  href="%{courseSearchFormCourseFormatSelect}"
>  cssStyle="width : 20em;"
>  headerValue="%{getText('course.search.header.format')}"
>  headerKey="-1"
>  list="groups"
>  listKey="id"
>  listValue="name"
>  name="searchCriteria.group"
>  onChangeTopics="courseFormatChanged"
>  indicator="courseSelectsFormatLoading"
>  value="1"
> />
>
> JSON Response:
> {"groups":[{"deleted":false,"id":1,"longName":"A Long
> Name","name":"Foo","sorting":null},{"deleted":false,"id":
> 2,"longName":null,"name":"Bar","sorting":null},{"deleted":false,"id":
> 3,"longName":null,"name":"Baz","sorting":null}],"localities":null,"searchCr­iteria":null,"templates":null}
>
> the value is set to "1" or "Foo" for testing. it dosent work ?
>
> struts-jquery-plugin: 2.5.1
> jquery: 1.4.4
>
> On 2 Apr., 20:21, jogep <joh...@googlemail.com> wrote:
>
>
>
> > the value attribute should work.
>
> > can you give a sample?
>
> > Johannes
> > ---
> > web:http://www.jgeppert.com
> > twitter:http://twitter.com/jogep
>
> > On 1 Apr., 18:21, skydiablo <hoessli...@nonacom.de> wrote:
>
> > > hiho...
>
> > > i have a "<sj:select ... />" tag, all works fine! but now, i want to
> > > preselect a item from the JSON result ? how can i do this ? i have try
> > > it with the "value" attribut, but nothing helps...
>
> > > greez & thx,
> > >   sky...- Hide quoted text -
>
> - Show quoted text -

skydiablo

unread,
Apr 4, 2011, 8:34:49 AM4/4/11
to struts2-jquery
okay, thx !!! works fine !

Ken

unread,
Dec 15, 2014, 8:31:51 AM12/15/14
to struts2...@googlegroups.com, hoess...@nonacom.de
Hi,

Same does not work if I set autocomplete to true in the sj:select. Can you please advise?

Thanks,
Ken

Vinay Kumar

unread,
Dec 17, 2014, 2:05:26 AM12/17/14
to struts2...@googlegroups.com, hoess...@nonacom.de
in struts you have to set the object in backend bean to the value select you desire.

the <s:select name=""/> name attribute help you out.

Thanks
vinu

--
You received this message because you are subscribed to the Google Groups "struts2-jquery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to struts2-jquer...@googlegroups.com.
To post to this group, send email to struts2...@googlegroups.com.
Visit this group at http://groups.google.com/group/struts2-jquery.
To view this discussion on the web visit https://groups.google.com/d/msgid/struts2-jquery/73225903-b387-4416-a1d0-c1b636551d97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages