aspose file tools*
The moose likes JSF and the fly likes selectOneMenu rendered while it shouldn't Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "selectOneMenu rendered while it shouldn Watch "selectOneMenu rendered while it shouldn New topic
Author

selectOneMenu rendered while it shouldn't

Rob HK
Greenhorn

Joined: Jul 26, 2005
Posts: 6
Hi,
I have the following code to create a selectOneMenu:
<h:selectOneMenu id="country" tabindex="12" value="#{myForm.country}" disabled="true"
>
<f:selectItems value="#{enumeratiesBean.countries}"/>
</h:selectOneMenu>

and it generates the following starttag:
<select id="body:myForm:country" name="body:myForm:country" size="1" tabindex="12">

The problem is that the disabled attribute is not being rendered at all. Does anyone know this problem?
Greets,
Rob
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Try disabled="disabled".

I think it's an html thing.


A good workman is known by his tools.
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
rendered = "false" work?
Rob HK
Greenhorn

Joined: Jul 26, 2005
Posts: 6
both disabled="disabled" and rendered="false" don't work
Grtz
Rob
Rob HK
Greenhorn

Joined: Jul 26, 2005
Posts: 6
Sorry....rendered="false" does work but i want to display the item as disabled instead of not showing it at all. Btw. readonly="true" doesn't work either.
Grtz,
Rob
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Not real sure. Works ok for me.



GenRocket - Experts at Building Test Data
Mauro Castaldo
Greenhorn

Joined: Jul 18, 2005
Posts: 22
Originally posted by Rob HK:
Hi,
I have the following code to create a selectOneMenu:
<h:selectOneMenu id="country" tabindex="12" value="#{myForm.country}" disabled="true"
>
<f:selectItems value="#{enumeratiesBean.countries}"/>
</h:selectOneMenu>

and it generates the following starttag:
<select id="body:myForm:country" name="body:myForm:country" size="1" tabindex="12">

The problem is that the disabled attribute is not being rendered at all. Does anyone know this problem?
Greets,
Rob


Are you using JSF reference implementation and, if so, which version?
Rob HK
Greenhorn

Joined: Jul 26, 2005
Posts: 6
We're using the Sun reference implementation version 1.1.
Mauro Castaldo
Greenhorn

Joined: Jul 18, 2005
Posts: 22
Originally posted by Rob HK:
We're using the Sun reference implementation version 1.1.


It works ok for me but I'm using latest JSF RI release. Try RI 1.1_01.
Rob HK
Greenhorn

Joined: Jul 26, 2005
Posts: 6
Hey guys,
Don't know what happened but suddenly it works ......maybe some duplicatie jsf library or so....anyway, thanx for replying.
Priti Shah
Ranch Hand

Joined: May 10, 2005
Posts: 43
Hi

Can you tell me how did you do that. I am having a same problem that I want to render SelectOneMenu but want to display it as disabled.

Actually I need to do this on checkbox selection. If checbox is not selected then SElectOneMenu is disabled. How can we access "Disabled" attribute in managed bean?

Thanks
Rob HK
Greenhorn

Joined: Jul 26, 2005
Posts: 6
Hi,
Well, i think for this occasion you could write a small javascript function to enable/disable the selectOneMenu if you check/uncheck the checkbox.
If you really want to disable the selectOneMenu through the backing bean i guess you could do something like this:

<h:selectOneMenu id="aId" value="#{aBean.value}" disabled="#{aBean.readOnly}"
<f:selectItems value="#{aBean.items}"/>
</h:selectOneMenu>

Where 'readOnly' is a method on the backingBean returning "true" or "false".
Hope this helps.
Priti Shah
Ranch Hand

Joined: May 10, 2005
Posts: 43
Thanks Rob

I used second approach and it works fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: selectOneMenu rendered while it shouldn't