*I need my check box list option to display vertically instead of the default horizontal display.I have created a folder in my src folder in the name templates and another folder with name vertical-checkbox containing the modified .ftl file of my customized check box list.I am unable to display the customized check box My code in JSP is
<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 getting wrong.
Normally the struts checkboxlist in struts2 diaply the check boxes horizontally. In most of application we want to display the check boxes vertically (line by line). For aligning this as vertical we have to do the following
You have to create a directory template in your src folder
Create a folder with the name of the template you want to create (vertical-checkbox)
Copy the struts-2.1.6/src/core/src/main/resources/template/simple/checkboxlist.ftl file to this directory content of this file is as follows. Before the you have to put a
tag as you want or like this link:
http://codeglobe.blogspot.com/2009/09/struts2-align-check-box-vertical.html
<s:checkboxlist list="urlist" name="selectedValues" listKey="id" listValue="descrption" theme="vertical-checkbox"></s:checkboxlist>
This will give you a vertical check box list. The only difference is that here you have to specify the theme which is same as the directory you have created in the template directory in the src folder of your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With