This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes How to diable a item in select option? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to diable a item in select option? " Watch "How to diable a item in select option? " New topic
Author

How to diable a item in select option?

tej ku
Greenhorn

Joined: Mar 13, 2010
Posts: 19
<!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

Joined: Feb 22, 2010
Posts: 23
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

Joined: Jun 25, 2001
Posts: 15952
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
tej ku
Greenhorn

Joined: Mar 13, 2010
Posts: 19
Hi Ganesh Podaralla,
Thanks for the reply, It is solved.......
Regards,
Ravi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to diable a item in select option?
 
Similar Threads
onclick event of command button change the state of radio button but onchange doe not
JSF - Missing source code using templating and composition
Multipart request problem
JSF Page Problem
Can't get JSF selectOneMenu to show list of items