RE: Problem passing interface implementing object to an action from a jsp

2009-02-04 Thread Mike Baranski
Yeah, I've created a LoginInterceptor to detect a session value if someone's 
logged in.  The main reason I did it was to understand the concept.

I will look into the prepare stuff, and just handle setting it myself.  What I 
did to make it work was change the Provider to have a lockDoor(doorId) method, 
and just passed the ID into the action from the jsp.

Thanks for the help.
Mike.

-
Mike Baranski
O: 919 788 9200
F: 919 510 0037
M: 919 395 0620

m...@secmgmt.com

CVI Authorized User Number: CVI-20080925-1020950
-

Warning: The information contained in this message may be privileged and 
confidential and protected from disclosure. If the reader of this message is 
not the intended recipient, you are hereby notified that any dissemination, 
distribution or copying of this communication is strictly prohibited. If you 
have received this communication in error, please notify the original sender 
immediately by replying to this message and then delete it from your computer. 
All e-mail sent to this address will be received by the SMC corporate e-mail 
system and are subject to archiving and review by someone other than the 
recipient.


-Original Message-
From: Adam Hardy [mailto:ahardy.str...@cyberspaceroad.com] 
Sent: Wednesday, February 04, 2009 12:39 PM
To: Struts Users Mailing List
Subject: Re: Problem passing interface implementing object to an action from a 
jsp

Technically you don't actually have to be that /smart/ to work it out, you just 
need to read the right documentation :)

I only do type conversion and instantiation of my model objects in one 
particular way and haven't a good overview of the other ways, such as via a 
prepare method.

It would help if someone who's more familiar with the out-of-the-box method 
would step in here to give you the lowdown rather than the vague stuff I can 
tell you.

Do you know what the interceptor stack is? If you're using the default, struts 
will call the prepare interceptor. Have you configured struts.xml to use any 
other interceptor stack? So that struts can do the prepare, you implement a 
prepare method from the prepare interface on your action which instantiates the 
entity beans and populates your action so that the xwork engine has got some 
bones to add the meat to. (It'll call the getDoor() to access your IDoor 
pre-instantiated objects).



Mike Baranski on 04/02/09 16:56, wrote:
> All I meant was that the value="[0]" evaluates to a Door object, which
> implements an IDoor, which I want to use for the setter method.
> 
> The documentation for type conversions says:
> 
> "The framework cannot instantiate an object if it can't determine an
> appropriate implementation. It recognizes well-known collection interfaces
> (List, Set, Map, etc) but cannot instantiate MyCustomInterface when all it
> sees is the interface. In this case, instantiate the target implementation
> first (eg. in a prepare method) or substitute in an implementation."
> 
> I'm not smart enough to understand what that means...
> 
> 
> -Original Message- From: Adam Hardy
> [mailto:ahardy.str...@cyberspaceroad.com] Sent: Wednesday, February 04, 2009
> 11:41 AM To: Struts Users Mailing List Subject: Re: Problem passing interface
> implementing object to an action from a jsp
> 
> Hi Mike,
> 
> I can't quite figure out what you're doing wrong. Don't know what you mean 
> exactly about the "iterator value" - but I guess the problem lies with the 
> config for your type conversions.
> 
> Do you have an xwork-conversions or an action-conversion.properties? That's 
> where you tell the xwork engine which converter to use for that class and
> setter.
> 
> Mike Baranski on 04/02/09 16:28, wrote:
>> Here's my delima:
>> 
>> I have an interface to represent a Door, called IDoor I have an interface
>> to represent a DoorProvider, called IDoorProvider.
>> 
>> I use Spring to inject the DoorProvider implementation for the particular 
>> application to get lists of doors.
>> 
>> I have an UnlockDoorAction that will unlock an IDoor implementing Door
>> (that comes from a provider)
>> 
>> Here is my UnlockDoorAction code that is relevant:
>> 
>> public String execute() throws Exception { this.getDoor().unlockDoor(-1); 
>> return SUCCESS; }
>> 
>> public IDoor getDoor() { return this.door; }
>> 
>> public void setDoor(IDoor cd) { this.door = cd; }
>> 
>> Here is the JSP code that causes this action to be executed:
>> 
>> > name="door" value="[0]"/> > alt=&qu

Re: Problem passing interface implementing object to an action from a jsp

2009-02-04 Thread Adam Hardy
Technically you don't actually have to be that /smart/ to work it out, you just 
need to read the right documentation :)


I only do type conversion and instantiation of my model objects in one 
particular way and haven't a good overview of the other ways, such as via a 
prepare method.


It would help if someone who's more familiar with the out-of-the-box method 
would step in here to give you the lowdown rather than the vague stuff I can 
tell you.


Do you know what the interceptor stack is? If you're using the default, struts 
will call the prepare interceptor. Have you configured struts.xml to use any 
other interceptor stack? So that struts can do the prepare, you implement a 
prepare method from the prepare interface on your action which instantiates the 
entity beans and populates your action so that the xwork engine has got some 
bones to add the meat to. (It'll call the getDoor() to access your IDoor 
pre-instantiated objects).




Mike Baranski on 04/02/09 16:56, wrote:

All I meant was that the value="[0]" evaluates to a Door object, which
implements an IDoor, which I want to use for the setter method.

The documentation for type conversions says:

"The framework cannot instantiate an object if it can't determine an
appropriate implementation. It recognizes well-known collection interfaces
(List, Set, Map, etc) but cannot instantiate MyCustomInterface when all it
sees is the interface. In this case, instantiate the target implementation
first (eg. in a prepare method) or substitute in an implementation."

I'm not smart enough to understand what that means...


-Original Message- From: Adam Hardy
[mailto:ahardy.str...@cyberspaceroad.com] Sent: Wednesday, February 04, 2009
11:41 AM To: Struts Users Mailing List Subject: Re: Problem passing interface
implementing object to an action from a jsp

Hi Mike,

I can't quite figure out what you're doing wrong. Don't know what you mean 
exactly about the "iterator value" - but I guess the problem lies with the 
config for your type conversions.


Do you have an xwork-conversions or an action-conversion.properties? That's 
where you tell the xwork engine which converter to use for that class and

setter.

Mike Baranski on 04/02/09 16:28, wrote:

Here's my delima:

I have an interface to represent a Door, called IDoor I have an interface
to represent a DoorProvider, called IDoorProvider.

I use Spring to inject the DoorProvider implementation for the particular 
application to get lists of doors.


I have an UnlockDoorAction that will unlock an IDoor implementing Door
(that comes from a provider)

Here is my UnlockDoorAction code that is relevant:

public String execute() throws Exception { this.getDoor().unlockDoor(-1); 
return SUCCESS; }


public IDoor getDoor() { return this.door; }

public void setDoor(IDoor cd) { this.door = cd; }

Here is the JSP code that causes this action to be executed:

name="door" value="[0]"/> 
alt="Locked" src=""
border="none"/>

Now, the value="[0]" is an iterator value of an object that implements the 
IDoor interface.


The Action returns "input", which (I think) is because it can't figure out 
how to set the parameter on the UnlockDoorAction.  How do I make the thing 
recognize that setDoor(IDoor cd) will take that parameter?



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



RE: Problem passing interface implementing object to an action from a jsp

2009-02-04 Thread Mike Baranski
All I meant was that the value="[0]" evaluates to a Door object, which 
implements an IDoor, which I want to use for the setter method.

The documentation for type conversions says:

"The framework cannot instantiate an object if it can't determine an 
appropriate implementation. It recognizes well-known collection interfaces 
(List, Set, Map, etc) but cannot instantiate MyCustomInterface when all it sees 
is the interface. In this case, instantiate the target implementation first 
(eg. in a prepare method) or substitute in an implementation."

I'm not smart enough to understand what that means...


-Original Message-
From: Adam Hardy [mailto:ahardy.str...@cyberspaceroad.com] 
Sent: Wednesday, February 04, 2009 11:41 AM
To: Struts Users Mailing List
Subject: Re: Problem passing interface implementing object to an action from a 
jsp

Hi Mike,

I can't quite figure out what you're doing wrong. Don't know what you mean 
exactly about the "iterator value" - but I guess the problem lies with the 
config for your type conversions.

Do you have an xwork-conversions or an action-conversion.properties? That's 
where you tell the xwork engine which converter to use for that class and 
setter.

Mike Baranski on 04/02/09 16:28, wrote:
> Here's my delima:
> 
> I have an interface to represent a Door, called IDoor
> I have an interface to represent a DoorProvider, called IDoorProvider.
> 
> I use Spring to inject the DoorProvider implementation for the particular
> application to get lists of doors.
> 
> I have an UnlockDoorAction that will unlock an IDoor implementing Door (that
> comes from a provider)
> 
> Here is my UnlockDoorAction code that is relevant:
> 
>   public String execute() throws Exception
> {
> this.getDoor().unlockDoor(-1);
> return SUCCESS;
> }
> 
>  public IDoor getDoor()
> {
> return this.door;
> }
> 
>  public void setDoor(IDoor cd)
> {
> this.door = cd;
> }
> 
> Here is the JSP code that causes this action to be executed:
> 
>  name="door" value="[0]"/>
> " border="none"/>
> 
> Now, the value="[0]" is an iterator value of an object that implements the
> IDoor interface.
> 
> The Action returns "input", which (I think) is because it can't figure out
> how to set the parameter on the UnlockDoorAction.  How do I make the thing
> recognize that setDoor(IDoor cd) will take that parameter?


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


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



Re: Problem passing interface implementing object to an action from a jsp

2009-02-04 Thread Adam Hardy

Hi Mike,

I can't quite figure out what you're doing wrong. Don't know what you mean 
exactly about the "iterator value" - but I guess the problem lies with the 
config for your type conversions.


Do you have an xwork-conversions or an action-conversion.properties? That's 
where you tell the xwork engine which converter to use for that class and setter.


Mike Baranski on 04/02/09 16:28, wrote:

Here's my delima:

I have an interface to represent a Door, called IDoor
I have an interface to represent a DoorProvider, called IDoorProvider.

I use Spring to inject the DoorProvider implementation for the particular
application to get lists of doors.

I have an UnlockDoorAction that will unlock an IDoor implementing Door (that
comes from a provider)

Here is my UnlockDoorAction code that is relevant:

public String execute() throws Exception
{
this.getDoor().unlockDoor(-1);
return SUCCESS;
}

 public IDoor getDoor()
{
return this.door;
}

 public void setDoor(IDoor cd)
{
this.door = cd;
}

Here is the JSP code that causes this action to be executed:


" border="none"/>

Now, the value="[0]" is an iterator value of an object that implements the
IDoor interface.

The Action returns "input", which (I think) is because it can't figure out
how to set the parameter on the UnlockDoorAction.  How do I make the thing
recognize that setDoor(IDoor cd) will take that parameter?



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