Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to diable a item in select option?

 
tej ku
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
 
Ganesh Podaralla
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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"}
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18162
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi Ganesh Podaralla,
Thanks for the reply, It is solved.......
Regards,
Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic