• 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

h:inputText readonly="true" not updating managed bean values

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use readonly="true" in h:inputText, hoping that the value will ultimately reach the managed bean property it is tied to, on submitting the form. The value gets submitted as a request parameter, but doesn't reach the managed bean it is tied to. I recollect facing the same problem some time back. Any ideas why the value is not reaching the managed bean.

Here is the code.



regards,
Nirvan
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Nirvan

I guess you must associate the inputText with a property in the managed bean

To do this instead of h:inputText use af:inputText where af is declared as xmlns:af="http://xmlns.oracle.com/adf/faces/rich"

Declare property in the bean and associate it using the binding attribute of the input text

Try iy like this

<af:inputText value="#{stateBean.selectedState}" readonly="true" binding="#{<managedbean>.<propriedad>}">
<f:converter converterId="stateConverter"/>
</af:inputText>

hope this can help you

Hugs

Américo
 
B Nirvan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not using oracle adf faces

regards,
Nirvan
 
Americo Pinto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't matter if it's Oracle or not.

The idea is always the same.

You must associate the inputText with a property in the bean

Hugs,

Américo
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not understand why would you transfer to using adf in any case. I do not see how the approach suggested by Americo Pinto solves anything.

Nirvan Buddha: Why would you like to send the state through user interface anyway? Do you have a good reason for doing so? User may found a way to change the property and then you have a potential security problem there.

I do not know why the readonly would prevent you getting the property back to bean but maybe it has something to do with the fact that readonly means just that (i.e. maybe JSF tries to prevent changing the property). But that is easy to test by removing the readonly and testing the code then.

If you absolutely must iterate the property through UI then then how about something like thisI did not test this.

EDIT: Maybe Americo Pinto wanted to use the value attribute of the binded component but he does not say so. And yes, that is one way of doing it if the value does indeed go to the binded component but does not populate to the value.
 
B Nirvan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Americo Pinto wrote:It doesn't matter if it's Oracle or not.

The idea is always the same.

You must associate the inputText with a property in the bean
Américo



Are you talking about value binding or component binding. I have already value-bound the h:inputText using
value="#{stateBean.selectedState}". If I remove readonly="true" the value very swiftly gets passed to the managed bean. My understanding of readonly is that it just disallows the user to edit the inputText. Other things function the same.
If you are talking about component binding, maybe it will work, but that doesn't answer the question why readonly should prevent updation of value-bound property in managed bean.

regards,
Nirvan.
 
Americo Pinto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everything you said is correct.

The attribute "value" works perfectly.

I don't know for what purpuse you have this inputText

If it's to be read only I don't know if it must be seen by the user or not.

If not you can use inputHidden instead

If yes try to use disabled instead of readonly

regards,

Américo
 
B Nirvan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Americo Pinto wrote:Everything you said is correct.

I don't know for what purpuse you have this inputText

If it's to be read only I don't know if it must be seen by the user or not.

If not you can use inputHidden instead

If yes try to use disabled instead of readonly

regards,
Américo



My managedBean is requestscoped so I am using the readonly inputText to get the value back next time when the bean is instantiated after form submit.

User needs to see it.

I can use inputHidden, or may be store the state attribute in session scope, or perhaps make the managed bean session scoped. But there will be other screens that will need this behaviour. So I am making sure the best approach is used.

disabled does not work.

regards,
Nirvan.

 
Americo Pinto
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the user needs to see it then put it readonly and copy the value into an inputHidden.

You can request for the value of the inputhidden field

Or put the value in the Session and request it as well on the bean

regards,

Américo
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need that your components be read only, you can do it using passthrough. Only need to do two things:

1.- Declare passthrough in the page. The next example is for an xhtml page.

2.- Write the attribute read only using passthrough for each input you need like this:

The a:readonly="readonly" is that, that you need.
 
reply
    Bookmark Topic Watch Topic
  • New Topic