java - Struts2, convert s:select list to display Tag column -


i have following selection list in jsp:

<td>     <s:select list = "models"           listvalue = "modelname"            listkey = "modelid"            multiple = "true"                name = "models" /> </td> 

i chose implement pagination display tag library, want convert in display column , show 1 ore more models list. how can this? below display table other columns:

<display:table name = "cars"           requesturi = "/listcar.action"             pagesize = "10">       <display:column property = "name" title = "name" />       <display:column titlekey = "models" >          <!--------------model list?-------------->      </display:column>        <display:column property = "year"  title = "year" />  </display:table> 

first of all, need make displaytag pushing value in context can access:

implicit objects created table


if add , id attribute table tag makes object corresponding given row available in page context use inside scriptlet code or other tag. implicit object exposed table tag row number, named id_rownum .

these objects saved attributes in page scope (you can access using pagecontext.getattribute("id") ). defined nested variables (accessible using <%=id%> ), if value of id atribute not runtime expression. preferred way fetching value use pagecontext.getattribute().

if not specify id attribute no object added pagecontext table tag


need access context. in struts2, pagecontext available through #attr:

struts 2 named objects:


#attr['foo'] or #attr.foo

access pagecontext if available, otherwise searches request/session/application respectively


so code be:

<display:table   id = "currentrowinpagecontext"                name = "cars"           requesturi = "/listcar.action"             pagesize = "10">       <display:column property = "name"  title = "name" />       <display:column titlekey = "models" >          <s:select list = "%{#attr.currentrowinpagecontext.models}"                listvalue = "modelname"                 listkey = "modelid"                 multiple = "true"                     name = "models" />      </display:column>                                                       <display:column property = "year" title = "year" />  </display:table> 


nowadays, however, there better alternatives displaytag, example jquery datatables , jquery jqgrid; latter there plugin (struts2-jquery-grid-plugin) helps use grid without knowing syntax, knowing struts2 tags.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -