Search code examples
javajspstruts2ognlstruts-tags

Use if/else within textfield?


I have already found several ways to use if / else tags and also how to use it within a <tr> tag.

But is it possible to use it within a <s:textfield> tag ?

I want to disable several fields (textfields and datepicker) if a certain parameter is true. At the moment, I have the whole code twice. Once with disable="true"and once without. This makes the jsp extremely verbose.

I would be very happy if there were a better/shorter way.


Solution

  • Try with this expression inside <s:textfield>

    disabled="%{myCondition}"
    

    where myCondition should evaluate to true or false.