I am using the following code but haven’t tried it yet:
<input type="checkbox" id="<bean:write name="element" property="idvalue" />" />
Is it valid ?
And how can it be acheived more efiiciently ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use server tags to initialize attributes of HTML tags. The code you posted is valid.
This code:
evaluates to
assuming that “theID” is what’s inside the “idvalue” property of your bean.
Off course this isn’t very easy to read even if you use JSTL as VinAy suggested. You will just ed up with something like this:
Again not easy to read if you have an entire JSP full of these.
The Struts html tags come in handy here and generate the input by using a construct like:
which, if you have it inside a <html:form> tag can be further simplified to:
And if all fails, you can always simplify it as much as you want by writing your own JSP custom tags.