Conditional XHTML attribute in JSPX

3

3W

Is there any way to have a conditional attribute on an XHTML element,
using JSPX (JSP in XML syntax)? Or any taglibs that'll do it?
More specifically, defining selected="selected" or checked="checked",
etc.

TIA,
 
E

Enrique

Would you provide an example of the desired output, and the conditions
that must be met for each?
 
3

3W

Would you provide an example of the desired output, and the conditions
that must be met for each?

public class SomeBean {
boolean checked;
public boolean isChecked() {
return isChecked;
}
}

Then in JSPX I would like the checkbox to be dependant on isChecked():

<input type="checkbox" name="someCheckbox"/>
or
<input type="checkbox" name="someCheckbox" checked="checked"/>
 
E

Enrique

Would this do?

<jsp:scriptlet>
if (myBean.isChecked())
{
</jsp:scriptlet>
<input type="checkbox" name="someCheckbox" checked="checked" />
<jsp:scriptlet>
}
else
{
</jsp:scriptlet>
<input type="checkbox" name="someCheckbox" />
<jsp:scriptlet>
}
</jsp:scriptlet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top