• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to diable a item in select option?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:e="http://rcx.el.func/SeamFunc"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:a="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:rcx="http://rcx.facelets/components">




<td><s:decorate>
<h:selectOneMenu id="readyToIssue"
value="#{suba na.requiredInd}">
<f:selectItem itemValue="Y" itemLabel="Yes" />
<f:selectItem itemValue="N" itemLabel="No" />
<f:selectItem itemValue="P" itemLabel="Processed" />
</h:selectOneMenu>
</s:decorate></td>
</tr>

There are three status of a field in database. If the database table has "P" state yes and no should be disabled and if "the status is "yes or no" "P" should be disabled.
we are using
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can write a method in the backing bean as below

public boolean isItemProcessed()
{
if("Processed".equals(data))
return true;
else
return false;
}

Then in the page,

<f:selectItem itemValue="Y" itemLabel="Yes" itemDisabled="#{!bean.isItemProcessed}"/>
<f:selectItem itemValue="N" itemLabel="No" itemDisabled="#{!bean.isItemProcessed}"/>
<f:selectItem itemValue="P" itemLabel="Processed" itemDisabled="#{bean.isItemProcessed}"/>

If you do not want to write a separate method, you can directly compare the data with itemDisabled="#{bean.data == "P"}" and itemDisabled="#{bean.data != "P"}
 
Saloon Keeper
Posts: 27888
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Somebody asked this question about 2-3 months ago. Search this forum and you'll find a detailed discussion about it.

Also, you can make your code and XML more readable if you use the "Code" button on our message editor.
 
tej ku
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ganesh Podaralla,
Thanks for the reply, It is solved.......
Regards,
Ravi
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic