Parameter setting <s: checkboxlist> is displayed vertically in struts2

* I need a checkbox option to display vertically instead of the default horizontal display. I created a folder in my src folder in the name templates and in another folder called vertical-checkbox containing the modified .ftl file of my custom checkbox. I can not display the custom checkbox My code in JSP

  <s:checkboxlist theme="vertical-checkbox" label="Which of the following are states of India"
                            name="states"
                                list="#{'01':'January','02':'February','03':'March','04':'April',
    '05':'May'}"
      />

Please advice where I am wrong.

+5
source share
5 answers

Typically, the layout flag of locations in struts2 horizontally adjusts the flags. In most applications, we want to display checkboxes vertically (row by row). To align vertically, we must do the following

. , , , , src .

+9

, , , , . , css:

<s:checkboxlist
  name="myCheckboxList"
  ... />

html- :

<input type="checkbox" id="myCheckboxList-1" ... />
<label for="myCheckboxList-1" ...
<input type="checkbox" id="myCheckboxList-2" ... />
<label for="myCheckboxList-2" ... 

CSS :

label[for*=myCheckboxList-]:after {
    content:"\A"; white-space:pre;
}

, " , " myCheckboxList- ", " ( "\ A" ) , ".

+6

: http://klyuty.blogspot.it/2011/03/creating-vertical-orientation-for.html , .

  • WEB-INF/classes .
  • WEB-INF/classes/template ( ).
  • checkboxlist.ftl struts2-core.jar(, jar).
  • ( . ):
for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}

:

</@s.iterator>

( ):

<#if parameters.cssStyle?exists>
<#if "${parameters.cssStyle?html}" == "vertical">
<br/><#rt/>
</#if>
</#if>

"vertical" - css, strust2,
- .

  1. struts2 s: checkboxlist "vertical" :

+2

.ftl, , , :

  • checkboxlist.ftl (,.../template)
  • checkboxLabel :

    <label ... class="checkboxLabel">
    <br>
    </@s.iterator>
    
  • / ... /template/checkboxlist.ftl, checkboxlist.ftl.

, CSS, .

0

. : http://mikeski.net/site/node/16

, :

  • checkboxlist.ftl
  • 3 , checkboxlist.ftl . , :

    <#include "/${parameters.templateDir}/simple/checkboxlist.ftl" />
    
  • freemarker, URL.

I did it and it worked for me. It will display your checkbox on a separate line.

0
source

All Articles