You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Milan Milanovic <mi...@yahoo.com> on 2008/11/28 18:48:53 UTC

[S2] Set textfield readonly property from action class

Hi,

I have defined edittingMode (String and boolean, I tried both) in my action
class with get/set methods and in resulting jsp I defined:

<s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>

But if I set edditingMode = "true" or edittingMode = true (in case of
boolean), textfield never become readonly! I'm using Struts 2.0.11.1. What
is the problem ?

--
Thx, Milan
-- 
View this message in context: http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20738164.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Set textfield readonly property from action class

Posted by st...@gmail.com.
I had my workspace nearby and here is the relevant content

MyAction
private boolean readOnly = false; get/set

MyPage
<s:textfield key="userName" readonly="%{readOnly}" size="40"
required="true"/>


Peace,
Scott
On Sun, Nov 30, 2008 at 5:10 AM, Milan Milanovic
<mi...@yahoo.com>wrote:

>
> No one knows how to do this simple thing ?
>
> --
> Milan
>
>
> Milan Milanovic wrote:
> >
> > Hi,
> >
> > I have defined edittingMode (String and boolean, I tried both) in my
> > action class with get/set methods and in resulting jsp I defined:
> >
> > <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
> >
> > But if I set edditingMode = "true" or edittingMode = true (in case of
> > boolean), textfield never become readonly! I'm using Struts 2.0.11.1.
> What
> > is the problem ?
> >
> > --
> > Thx, Milan
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] Set textfield readonly property from action class

Posted by Milan Milanovic <mi...@yahoo.com>.
Yes, that was the problem. Thank you all.

--
Milan


stanlick wrote:
> 
>> <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
> 
> As I was pressing send, I noticed you have a closing parenthesis instead
> of
> brace!  That is not going to be good for anyone.
> 
> 
> 
> 
> On Sun, Nov 30, 2008 at 5:10 AM, Milan Milanovic
> <mi...@yahoo.com>wrote:
> 
>>
>> No one knows how to do this simple thing ?
>>
>> --
>> Milan
>>
>>
>> Milan Milanovic wrote:
>> >
>> > Hi,
>> >
>> > I have defined edittingMode (String and boolean, I tried both) in my
>> > action class with get/set methods and in resulting jsp I defined:
>> >
>> > <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
>> >
>> > But if I set edditingMode = "true" or edittingMode = true (in case of
>> > boolean), textfield never become readonly! I'm using Struts 2.0.11.1.
>> What
>> > is the problem ?
>> >
>> > --
>> > Thx, Milan
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20759543.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Set textfield readonly property from action class

Posted by st...@gmail.com.
> <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>

As I was pressing send, I noticed you have a closing parenthesis instead of
brace!  That is not going to be good for anyone.




On Sun, Nov 30, 2008 at 5:10 AM, Milan Milanovic
<mi...@yahoo.com>wrote:

>
> No one knows how to do this simple thing ?
>
> --
> Milan
>
>
> Milan Milanovic wrote:
> >
> > Hi,
> >
> > I have defined edittingMode (String and boolean, I tried both) in my
> > action class with get/set methods and in resulting jsp I defined:
> >
> > <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
> >
> > But if I set edditingMode = "true" or edittingMode = true (in case of
> > boolean), textfield never become readonly! I'm using Struts 2.0.11.1.
> What
> > is the problem ?
> >
> > --
> > Thx, Milan
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] Set textfield readonly property from action class

Posted by st...@gmail.com.
I have used this technique and it works fine.  Perhaps you should simply
display the property on the web page to see what it actually contains.

On Sun, Nov 30, 2008 at 7:21 AM, Milan Milanovic
<mi...@yahoo.com>wrote:

>
> Dear Khawaja,
>
> Thanks. I tried with Boolean too for action class "edittinMode" type, and
> "disable" property and it doesn't work too. So, I must use "request" ?
>
> --
> Milan.
>
>
> Khawaja-Shahzad Butt wrote:
> >
> > Hi Milan,
> >
> > Can you try this in your action class.
> >
> > if(your condition for setting editable mode is true)
> > request.setAttribute("edittingMode",true);
> > else
> > request.setAttribute("edittingMode",false);
> >
> >
> > or another way
> >
> > String edittingMode= "false";
> > if(your condition for setting editable mode is true)
> > {
> > edittingMode = "true";
> > request.setAttribute("edittingMode",edittingMode );
> > }
> > else
> > {
> > request.setAttribute("edittingMode",false);
> > }
> >
> >
> >
> > I am sure you are already doing that. I think readonly works best on the
> > textarea and not textfield. try disabled instead of readonly and i am
> sure
> > it will work.
> > See the docs here.
> >
> > http://struts.apache.org/2.x/docs/textfield.html
> >
> >
> > Hope it helps.
> >
> >
> > On Sun, Nov 30, 2008 at 5:10 AM, Milan Milanovic <> wrote:
> >
> >>
> >> No one knows how to do this simple thing ?
> >>
> >> --
> >> Milan
> >>
> >>
> >> Milan Milanovic wrote:
> >> >
> >> > Hi,
> >> >
> >> > I have defined edittingMode (String and boolean, I tried both) in my
> >> > action class with get/set methods and in resulting jsp I defined:
> >> >
> >> > <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
> >> >
> >> > But if I set edditingMode = "true" or edittingMode = true (in case of
> >> > boolean), textfield never become readonly! I'm using Struts 2.0.11.1.
> >> What
> >> > is the problem ?
> >> >
> >> > --
> >> > Thx, Milan
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20757621.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] Set textfield readonly property from action class

Posted by Milan Milanovic <mi...@yahoo.com>.
Dear Khawaja,

Thanks. I tried with Boolean too for action class "edittinMode" type, and
"disable" property and it doesn't work too. So, I must use "request" ? 

--
Milan.


Khawaja-Shahzad Butt wrote:
> 
> Hi Milan,
> 
> Can you try this in your action class.
> 
> if(your condition for setting editable mode is true)
> request.setAttribute("edittingMode",true);
> else
> request.setAttribute("edittingMode",false);
> 
> 
> or another way
> 
> String edittingMode= "false";
> if(your condition for setting editable mode is true)
> {
> edittingMode = "true";
> request.setAttribute("edittingMode",edittingMode );
> }
> else
> {
> request.setAttribute("edittingMode",false);
> }
> 
> 
> 
> I am sure you are already doing that. I think readonly works best on the
> textarea and not textfield. try disabled instead of readonly and i am sure
> it will work.
> See the docs here.
> 
> http://struts.apache.org/2.x/docs/textfield.html
> 
> 
> Hope it helps.
> 
> 
> On Sun, Nov 30, 2008 at 5:10 AM, Milan Milanovic <> wrote:
> 
>>
>> No one knows how to do this simple thing ?
>>
>> --
>> Milan
>>
>>
>> Milan Milanovic wrote:
>> >
>> > Hi,
>> >
>> > I have defined edittingMode (String and boolean, I tried both) in my
>> > action class with get/set methods and in resulting jsp I defined:
>> >
>> > <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
>> >
>> > But if I set edditingMode = "true" or edittingMode = true (in case of
>> > boolean), textfield never become readonly! I'm using Struts 2.0.11.1.
>> What
>> > is the problem ?
>> >
>> > --
>> > Thx, Milan
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20757621.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Set textfield readonly property from action class

Posted by Khawaja-Shahzad Butt <ks...@gmail.com>.
Hi Milan,

Can you try this in your action class.

if(your condition for setting editable mode is true)
request.setAttribute("edittingMode",true);
else
request.setAttribute("edittingMode",false);


or another way

String edittingMode= "false";
if(your condition for setting editable mode is true)
{
edittingMode = "true";
request.setAttribute("edittingMode",edittingMode );
}
else
{
request.setAttribute("edittingMode",false);
}



I am sure you are already doing that. I think readonly works best on the
textarea and not textfield. try disabled instead of readonly and i am sure
it will work.
See the docs here.

http://struts.apache.org/2.x/docs/textfield.html


Hope it helps.


On Sun, Nov 30, 2008 at 5:10 AM, Milan Milanovic <> wrote:

>
> No one knows how to do this simple thing ?
>
> --
> Milan
>
>
> Milan Milanovic wrote:
> >
> > Hi,
> >
> > I have defined edittingMode (String and boolean, I tried both) in my
> > action class with get/set methods and in resulting jsp I defined:
> >
> > <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
> >
> > But if I set edditingMode = "true" or edittingMode = true (in case of
> > boolean), textfield never become readonly! I'm using Struts 2.0.11.1.
> What
> > is the problem ?
> >
> > --
> > Thx, Milan
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

[OT] Re: [S2] Set textfield readonly property from action class

Posted by Dave Newton <ne...@yahoo.com>.
--- On Sun, 11/30/08, Milan Milanovic wrote:
> No one knows how to do this simple thing ?

Berating us may not help.

The first thing I'd try is using the attribute properly:

http://www.w3schools.com/TAGS/att_input_readonly.asp

Then check to make sure it's rendered properly. If it's rendering properly then post to an HTML/browser-oriented group/list/forum. If it isn't being rendered properly then file a JIRA.

Dave


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


Re: [S2] Set textfield readonly property from action class

Posted by Milan Milanovic <mi...@yahoo.com>.
No one knows how to do this simple thing ?

--
Milan


Milan Milanovic wrote:
> 
> Hi,
> 
> I have defined edittingMode (String and boolean, I tried both) in my
> action class with get/set methods and in resulting jsp I defined:
> 
> <s:textfield id="id" label="Id" name="id" readonly="%{edittingMode)"/>
> 
> But if I set edditingMode = "true" or edittingMode = true (in case of
> boolean), textfield never become readonly! I'm using Struts 2.0.11.1. What
> is the problem ?
> 
> --
> Thx, Milan
> 

-- 
View this message in context: http://www.nabble.com/-S2--Set-textfield-readonly-property-from-action-class-tp20738164p20756552.html
Sent from the Struts - User mailing list archive at Nabble.com.


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