Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable html button using JSTL tags

Tags:

spring

jstl

I want disable HTML button depending on value present in Spring bean.I am using JSTL empty property but no luck.
Here is my code

   <input type="submit" value="SendEmail" disabled="${empty reportNotificationFbo.providersList}" >  

Here reportNotificationFbo is spring bean and providersList is a list.

I want to disable Submit button if providersList is empty.

-Thanks.

like image 374
Ajinkya Avatar asked May 17 '11 10:05

Ajinkya


People also ask

Can we use JSTL tags in HTML?

No. It is not possible to have JSTL in HTML page.

How can disable a button based on condition in JSP?

stackoverflow.com. how can I disable a button by checking a condition in my jsp? If true,then the button is enabled,if false,then the button is disabled. The condition would be checking the value ...

What is the difference between JSP and JSTL?

JSP lets you even define your own tags (you must write the code that actually implement the logic of those tags in Java). JSTL is just a standard tag library provided by Sun (well, now Oracle) to carry out common tasks (such as looping, formatting, etc.).

What is the use of JSTL dependency?

JSTL stands for JSP Standard Tag Library. JSTL is the standard tag library that provides tags to control the JSP page behavior. JSTL tags can be used for iteration and control statements, internationalization, SQL etc.


1 Answers

State of the button is controlled by the presence of disabled attribute, not by its value. Try the following:

<input type="submit" value="SendEmail"
    "${(empty reportNotificationFbo.providersList) ? 'disabled' : ''}" >   
like image 137
axtavt Avatar answered Oct 12 '22 23:10

axtavt