You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arne Brutschy <ma...@studserv.uni-leipzig.de> on 2004/02/12 14:31:46 UTC

Getting data from a disabled form field

Hi,

I have a problem with disabled form fields. I'm using a user entry form, 
which fields can be edited by the current user based on his group 
memberships. So a normal user without admin status cannot change the 
uid, as this field is disabled.

My problem is, that after submitting the form, validation fails because 
of the validator which cannot read the uids field context (I assume 
because it's disabled). Trying to get the form data returns an empty string.

Anyone encountered this type of problem? Is there any way around it?

Regards,
Arne


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Getting data from a disabled form field

Posted by Angharad Stapleton <a_...@chiconi.com>.
Try using Javascript to re-enable the fields when the form is submitted,
this allows them to be passed through to the form as normal.

-----Original Message-----
From: Mark Lowe [mailto:mark.lowe@talk21.com]
Sent: 12 February 2004 13:46
To: Struts Users Mailing List
Subject: Re: Getting data from a disabled form field


i believe that disabled form elements return null.

I hate to say it, but you could have the uid stored as a hidden
variable in the case of the non admin user but still display a text
field with the value displayed.


On 12 Feb 2004, at 14:31, Arne Brutschy wrote:

> Hi,
>
> I have a problem with disabled form fields. I'm using a user entry
> form, which fields can be edited by the current user based on his
> group memberships. So a normal user without admin status cannot change
> the uid, as this field is disabled.
>
> My problem is, that after submitting the form, validation fails
> because of the validator which cannot read the uids field context (I
> assume because it's disabled). Trying to get the form data returns an
> empty string.
>
> Anyone encountered this type of problem? Is there any way around it?
>
> Regards,
> Arne
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Getting data from a disabled form field

Posted by Andrew Hill <an...@gridnode.com>.
They dont submit any parameter in the posted request. As a result, when
struts populates the form, iterating the list of request parameters and
calling the setters with the values it wont call the setter for that one.

The value in the actionform thus depends upon the logic in the forms reset
method - and if that field is not reset, upon the pre-existing value in the
actionform which will remain unchanged. In the case of a request scoped
form, this will of course be a new actionform instance so will give whatever
the forms initial value is when the form is created. (Usually null)

-----Original Message-----
From: Mark Lowe [mailto:mark.lowe@talk21.com]
Sent: Thursday, 12 February 2004 21:46
To: Struts Users Mailing List
Subject: Re: Getting data from a disabled form field


i believe that disabled form elements return null.

I hate to say it, but you could have the uid stored as a hidden
variable in the case of the non admin user but still display a text
field with the value displayed.


On 12 Feb 2004, at 14:31, Arne Brutschy wrote:

> Hi,
>
> I have a problem with disabled form fields. I'm using a user entry
> form, which fields can be edited by the current user based on his
> group memberships. So a normal user without admin status cannot change
> the uid, as this field is disabled.
>
> My problem is, that after submitting the form, validation fails
> because of the validator which cannot read the uids field context (I
> assume because it's disabled). Trying to get the form data returns an
> empty string.
>
> Anyone encountered this type of problem? Is there any way around it?
>
> Regards,
> Arne
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Getting data from a disabled form field

Posted by Mark Lowe <ma...@talk21.com>.
i believe that disabled form elements return null.

I hate to say it, but you could have the uid stored as a hidden 
variable in the case of the non admin user but still display a text 
field with the value displayed.


On 12 Feb 2004, at 14:31, Arne Brutschy wrote:

> Hi,
>
> I have a problem with disabled form fields. I'm using a user entry 
> form, which fields can be edited by the current user based on his 
> group memberships. So a normal user without admin status cannot change 
> the uid, as this field is disabled.
>
> My problem is, that after submitting the form, validation fails 
> because of the validator which cannot read the uids field context (I 
> assume because it's disabled). Trying to get the form data returns an 
> empty string.
>
> Anyone encountered this type of problem? Is there any way around it?
>
> Regards,
> Arne
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Getting data from a disabled form field

Posted by Andrew Hill <an...@gridnode.com>.
Yep. The browser doesnt submit a value for the field if its disabled.

If your using a request scoped actionform then you will either need to
reload its value from <wherever> or add an additional hidden field on the
form to submit the value. If its a session scoped form, just make sure that
you dont clear it in reset.

btw: if this is a security thing then you must make sure that your setters
(or something else server side) dont accept different values for these
fields when the user hasnt got appropriate rights as a user can easily play
silly buggers with the url and script kiddies can easily spoof POST
requests - both bypassing any kind of client side validation or 'security'.

-----Original Message-----
From: Arne Brutschy [mailto:mai01cvr@studserv.uni-leipzig.de]
Sent: Thursday, 12 February 2004 21:32
To: Struts Users Mailing List
Subject: Getting data from a disabled form field


Hi,

I have a problem with disabled form fields. I'm using a user entry form,
which fields can be edited by the current user based on his group
memberships. So a normal user without admin status cannot change the
uid, as this field is disabled.

My problem is, that after submitting the form, validation fails because
of the validator which cannot read the uids field context (I assume
because it's disabled). Trying to get the form data returns an empty string.

Anyone encountered this type of problem? Is there any way around it?

Regards,
Arne


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org