You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by akash agrawal <ak...@yahoo.co.uk> on 2008/04/04 19:37:17 UTC

Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Hi,

Struts 2 tags have value attribute where name of property is used to read the value from the bean. If the property is lets say xyz, tag looks for getXyz(). Is this possible to customize that so that instead of getXyz(), it looks for isXyz()? My boolean property has accessors which starts with isXyz() instead of getXyz().

Thx

-Akash



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by Laurie Harper <la...@holoweb.net>.
David Durham, Jr. wrote:
> On Fri, Apr 4, 2008 at 1:39 PM, akash agrawal <ak...@yahoo.co.uk> wrote:
>>  It is a Boolean property but I still think it should work no matter whether it is boolean or Boolean. APIs I am using are not mine so I can't change the bean, but there are workaround I can put in although they aren't pretty. I was hoping something can be done on the framework (Struts2) side.
> 
> Ask not what the framework can do for you, but what you can do for the
> framework ...   it's Friday.  Seriously though, if you need to provide
> a getMyBoolean, and you can't modify the original class, you can just
> provide a wrapper to translate getMyBoolean to isMyBoolean.  If it's a
> public class as I think the JavaBean spec requires it to be, you can
> just extend it, otherwise you need a delegator for not just this
> property but all the others.  Anyway, it's not really clear that this
> is what you need anyway, so this is just more speculation.

The JavaBean specification only talks about boolean properties; it 
doesn't mention Boolean (section 8.3.2). But rather than messing with an 
'adapter' sub-class, I would consider either (a) creating a BeanInfo 
class or (b) simply living with it and just being explicit in OGNL 
expressions like so:

<s:checkbox name="xyz" label="xyzLabel" value="%{#myBean.isXyz()}" 
required="true" tooltip="xyzTooltip"/>

i.e. use method-call rather than simple property syntax.

L.


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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by "David Durham, Jr." <da...@gmail.com>.
On Fri, Apr 4, 2008 at 1:39 PM, akash agrawal <ak...@yahoo.co.uk> wrote:
>  It is a Boolean property but I still think it should work no matter whether it is boolean or Boolean. APIs I am using are not mine so I can't change the bean, but there are workaround I can put in although they aren't pretty. I was hoping something can be done on the framework (Struts2) side.

Ask not what the framework can do for you, but what you can do for the
framework ...   it's Friday.  Seriously though, if you need to provide
a getMyBoolean, and you can't modify the original class, you can just
provide a wrapper to translate getMyBoolean to isMyBoolean.  If it's a
public class as I think the JavaBean spec requires it to be, you can
just extend it, otherwise you need a delegator for not just this
property but all the others.  Anyway, it's not really clear that this
is what you need anyway, so this is just more speculation.


--Dave

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by akash agrawal <ak...@yahoo.co.uk>.
David,

It is a Boolean property but I still think it should work no matter whether it is boolean or Boolean. APIs I am using are not mine so I can't change the bean, but there are workaround I can put in although they aren't pretty. I was hoping something can be done on the framework (Struts2) side.

Thx.
-Akash


--- On Fri, 4/4/08, David Durham, Jr. <da...@gmail.com> wrote:

> From: David Durham, Jr. <da...@gmail.com>
> Subject: Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()
> To: "Struts Users Mailing List" <us...@struts.apache.org>, akash_agrawal@yahoo.co.uk
> Date: Friday, April 4, 2008, 11:33 AM
> On Fri, Apr 4, 2008 at 1:17 PM, akash agrawal
> <ak...@yahoo.co.uk> wrote:
> > myBean is not null, There are other field which are
> not boolean and I do get them fine.
> 
> Is it boolean, or Boolean?  I've seen situations where
> I was hoping
> isX would return a reference to a Boolean (when reference
> with
> JavaBean dot notation), but I had to implement a getX
> instead.  Just 2
> cents.
> 
> -Dave
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org


      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by "David Durham, Jr." <da...@gmail.com>.
On Fri, Apr 4, 2008 at 1:17 PM, akash agrawal <ak...@yahoo.co.uk> wrote:
> myBean is not null, There are other field which are not boolean and I do get them fine.

Is it boolean, or Boolean?  I've seen situations where I was hoping
isX would return a reference to a Boolean (when reference with
JavaBean dot notation), but I had to implement a getX instead.  Just 2
cents.

-Dave

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by akash agrawal <ak...@yahoo.co.uk>.
myBean is not null, There are other field which are not boolean and I do get them fine.

Thx

--- On Fri, 4/4/08, Musachy Barroso <mu...@gmail.com> wrote:

> From: Musachy Barroso <mu...@gmail.com>
> Subject: Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Friday, April 4, 2008, 11:09 AM
> Are you sure that "myBean" is not null?
> 
> musachy
> 
> On Fri, Apr 4, 2008 at 2:05 PM, akash agrawal
> <ak...@yahoo.co.uk> wrote:
> > Here is my JSP snippet. isXyz() does not work for me.
> What am I doing incorrectly?
> >
> >  <s:set name="myBean"
> value="myBeanObject"></s:set>
> >
> >  <s:checkbox name="xyz"
> label="xyzLabel" value="%{#myBean.xyz}"
> required="true"
> tooltip="xyzTooltip"/>
> >
> >  Thx.
> >
> >
> >  --- On Fri, 4/4/08, Musachy Barroso
> <mu...@gmail.com> wrote:
> >
> >  > From: Musachy Barroso <mu...@gmail.com>
> >  > Subject: Re: Struts2 tags behaviour
> customizable? isXyz() instead of getXyz()
> >  > To: "Struts Users Mailing List"
> <us...@struts.apache.org>
> >  > Date: Friday, April 4, 2008, 10:47 AM
> >
> >
> > > Struts 2(OGNL technically speaking) will call
> getX() or
> >  > isX() if one
> >  > of them exist, when "y.x" is
> evaluated.
> >  >
> >  > musachy
> >  >
> >  > On Fri, Apr 4, 2008 at 1:37 PM, akash agrawal
> >  > <ak...@yahoo.co.uk> wrote:
> >  > > Hi,
> >  > >
> >  > >  Struts 2 tags have value attribute where
> name of
> >  > property is used to read the value from the
> bean. If the
> >  > property is lets say xyz, tag looks for
> getXyz(). Is this
> >  > possible to customize that so that instead of
> getXyz(), it
> >  > looks for isXyz()? My boolean property has
> accessors which
> >  > starts with isXyz() instead of getXyz().
> >  > >
> >  > >  Thx
> >  > >
> >  > >  -Akash
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  >
> ____________________________________________________________________________________
> >  > >  You rock. That's why Blockbuster's
> offering
> >  > you one month of Blockbuster Total Access, No
> Cost.
> >  > > 
> http://tc.deals.yahoo.com/tc/blockbuster/text5.com
> >  > >
> >  > >
> >  >
> ---------------------------------------------------------------------
> >  > >  To unsubscribe, e-mail:
> >  > user-unsubscribe@struts.apache.org
> >  > >  For additional commands, e-mail:
> >  > user-help@struts.apache.org
> >  > >
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > "Hey you! Would you help me to carry the
> stone?"
> >  > Pink Floyd
> >  >
> >  >
> ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> >  > For additional commands, e-mail:
> >  > user-help@struts.apache.org
> >
> >
> >      
> ____________________________________________________________________________________
> >  You rock. That's why Blockbuster's offering
> you one month of Blockbuster Total Access, No Cost.
> >  http://tc.deals.yahoo.com/tc/blockbuster/text5.com
> >
> > 
> ---------------------------------------------------------------------
> >  To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> >  For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?"
> Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org


      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by Musachy Barroso <mu...@gmail.com>.
Are you sure that "myBean" is not null?

musachy

On Fri, Apr 4, 2008 at 2:05 PM, akash agrawal <ak...@yahoo.co.uk> wrote:
> Here is my JSP snippet. isXyz() does not work for me. What am I doing incorrectly?
>
>  <s:set name="myBean" value="myBeanObject"></s:set>
>
>  <s:checkbox name="xyz" label="xyzLabel" value="%{#myBean.xyz}" required="true" tooltip="xyzTooltip"/>
>
>  Thx.
>
>
>  --- On Fri, 4/4/08, Musachy Barroso <mu...@gmail.com> wrote:
>
>  > From: Musachy Barroso <mu...@gmail.com>
>  > Subject: Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()
>  > To: "Struts Users Mailing List" <us...@struts.apache.org>
>  > Date: Friday, April 4, 2008, 10:47 AM
>
>
> > Struts 2(OGNL technically speaking) will call getX() or
>  > isX() if one
>  > of them exist, when "y.x" is evaluated.
>  >
>  > musachy
>  >
>  > On Fri, Apr 4, 2008 at 1:37 PM, akash agrawal
>  > <ak...@yahoo.co.uk> wrote:
>  > > Hi,
>  > >
>  > >  Struts 2 tags have value attribute where name of
>  > property is used to read the value from the bean. If the
>  > property is lets say xyz, tag looks for getXyz(). Is this
>  > possible to customize that so that instead of getXyz(), it
>  > looks for isXyz()? My boolean property has accessors which
>  > starts with isXyz() instead of getXyz().
>  > >
>  > >  Thx
>  > >
>  > >  -Akash
>  > >
>  > >
>  > >
>  > >
>  > >
>  > ____________________________________________________________________________________
>  > >  You rock. That's why Blockbuster's offering
>  > you one month of Blockbuster Total Access, No Cost.
>  > >  http://tc.deals.yahoo.com/tc/blockbuster/text5.com
>  > >
>  > >
>  > ---------------------------------------------------------------------
>  > >  To unsubscribe, e-mail:
>  > user-unsubscribe@struts.apache.org
>  > >  For additional commands, e-mail:
>  > user-help@struts.apache.org
>  > >
>  > >
>  >
>  >
>  >
>  > --
>  > "Hey you! Would you help me to carry the stone?"
>  > Pink Floyd
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  > For additional commands, e-mail:
>  > user-help@struts.apache.org
>
>
>       ____________________________________________________________________________________
>  You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
>  http://tc.deals.yahoo.com/tc/blockbuster/text5.com
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by akash agrawal <ak...@yahoo.co.uk>.
Here is my JSP snippet. isXyz() does not work for me. What am I doing incorrectly?

<s:set name="myBean" value="myBeanObject"></s:set>

<s:checkbox name="xyz" label="xyzLabel" value="%{#myBean.xyz}" required="true" tooltip="xyzTooltip"/>

Thx.


--- On Fri, 4/4/08, Musachy Barroso <mu...@gmail.com> wrote:

> From: Musachy Barroso <mu...@gmail.com>
> Subject: Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Friday, April 4, 2008, 10:47 AM
> Struts 2(OGNL technically speaking) will call getX() or
> isX() if one
> of them exist, when "y.x" is evaluated.
> 
> musachy
> 
> On Fri, Apr 4, 2008 at 1:37 PM, akash agrawal
> <ak...@yahoo.co.uk> wrote:
> > Hi,
> >
> >  Struts 2 tags have value attribute where name of
> property is used to read the value from the bean. If the
> property is lets say xyz, tag looks for getXyz(). Is this
> possible to customize that so that instead of getXyz(), it
> looks for isXyz()? My boolean property has accessors which
> starts with isXyz() instead of getXyz().
> >
> >  Thx
> >
> >  -Akash
> >
> >
> >
> >
> >      
> ____________________________________________________________________________________
> >  You rock. That's why Blockbuster's offering
> you one month of Blockbuster Total Access, No Cost.
> >  http://tc.deals.yahoo.com/tc/blockbuster/text5.com
> >
> > 
> ---------------------------------------------------------------------
> >  To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> >  For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?"
> Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org


      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

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


Re: Struts2 tags behaviour customizable? isXyz() instead of getXyz()

Posted by Musachy Barroso <mu...@gmail.com>.
Struts 2(OGNL technically speaking) will call getX() or isX() if one
of them exist, when "y.x" is evaluated.

musachy

On Fri, Apr 4, 2008 at 1:37 PM, akash agrawal <ak...@yahoo.co.uk> wrote:
> Hi,
>
>  Struts 2 tags have value attribute where name of property is used to read the value from the bean. If the property is lets say xyz, tag looks for getXyz(). Is this possible to customize that so that instead of getXyz(), it looks for isXyz()? My boolean property has accessors which starts with isXyz() instead of getXyz().
>
>  Thx
>
>  -Akash
>
>
>
>
>       ____________________________________________________________________________________
>  You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
>  http://tc.deals.yahoo.com/tc/blockbuster/text5.com
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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