« Return to Thread: RE: signatures help

Re: signatures help

by David Marginian-2 :: Rate this Message:

Reply to Author | View in Thread

Ty,
   Well this is definitely not the first time I have been wrong.  I ran
a few tests and you are correct.  I don't think the issue has been
resolved yet (even for 3.0m2).  It is scheduled for that release but the
issue is still open.

tyju tiui wrote:

> Hi Dave,
>
> It's very clear that the problem is real.
> The original code where I discovered the problem throws a ClassCastException and plainly shows that a java.lang.String cannot be cast to [Ljava.lang.String;
> Its unambiguous ... even still, I wrote another test implementing your suggested technique just to be sure:
>
> import java.util.Map;
> import java.util.HashMap;
>
> public class ParamActions{
>
>     public static void main(String[] args){
>         Map params = new HashMap();
>         params.put("myArr", new String[]{"a", "b", "c"});
>         System.out.println("passed in a String[] : " + storeParams(params));
>     }
>    
>     public static boolean storeParams(Map params){
>
>         boolean pass = false;
>        
>         try{
>             if(params.get("myArr").getClass().equals(Class.forName("[Ljava.lang.String;"))){
>                 pass = true;
>             }else if(params.get("myArr") instanceof java.lang.String[]){
>                 pass = true;
>             }
>         }catch(Exception e){
>             e.printStackTrace();
>         }
>
>         return pass;
>        
>     }
> }
>
> The results are always the same ... called without DWR the method evaluates to true, with DWR it evaluates to false.
> I've taken out all variables and am just testing from the debugging interface generated by DWR. I plugin {'myArr':["a","b","c"]} and it returns false.
>
> Thanks again for trying to help,
>
> Ty
>
>
>
> ----- Original Message ----
> From: "david@..." <david@...>
> To: users@...
> Sent: Wednesday, April 23, 2008 4:57:23 PM
> Subject: Re: [dwr-user] signatures help
>
> I understand that you this is your test for DWR. Have you ever thought the
> Java code you have written is not correct (it doesn't look correct to me)
> and that DWR is passing everything correctly?  I can assure you that this
> is a very common feature and DWR fully supports it and it works correctly.
>
> Write a test for your method in Java outside of DWR.  If you are not
> familiar with junit/testng add a main method, create a test map and pass it
> to your method.  
>
> public static void main(String[] args) throws Exception {
>     Map testMap = new HashMap();
>     String[] newStringArr = {"A",    "B"    };
>     testMap.put("myArr", newStringArr);
>     System.out.println(storeParams(testMap));
> }
>
> Your test to see what is in the map does not seem correct to me.  Try
> something like:
> if(params.get("myArr") instanceof java.lang.String[])
>
>
>
>
>
>
> Original Message:
> -----------------
> From: tyju tiui jckdnk111@...
> Date: Wed, 23 Apr 2008 13:30:16 -0700 (PDT)
> To: users@...
> Subject: Re: [dwr-user] signatures help
>
>
> Hi Dave,
>
> This is actually the test :-)
> I'm testing to see if DWR is passing in a String[] and it isn't.
>
> As another test, I tried passing in another hash object instead of an array
> of strings and the result was the same ... DWR fills the container Map with
> Strings regardless of what's passed in on the remote side.
>
> I expect a Map<String, String[]> or in the second test a Map<String, Map>
> but always receive Map<String, String>.
>
> It seems the previously reported bug might actually be a bug
> (http://getahead.org/bugs/browse/DWR-96)
>
> Thanks again for your help,
>
> Ty
>
> ----- Original Message ----
> From: "david@..." <david@...>
> To: users@...
> Sent: Wednesday, April 23, 2008 1:59:26 PM
> Subject: Re: [dwr-user] signatures help
>
> Sorry, I missed that.  You still do not need signatures.  What you are
> sending to your java method is fine.
>
> It looks to me that your Java code and logic is at fault.  
> 1) Add a breakpoint to your Java method and debug it.
> 2) Write a test case and verify that the method performs as expected.
>
> Original Message:
> -----------------
> From: tyju tiui jckdnk111@...
> Date: Wed, 23 Apr 2008 10:41:39 -0700 (PDT)
> To: users@...
> Subject: Re: [dwr-user] signatures help
>
>
> Hi Dave,
>
> Thanks for the quick reply.
> If you look closely at my original e-mail you'll see that I am, indeed,
> sending a remote js hash.
> It just so happens that the hash contains an array of strings.
>
> Ty
>
> ----- Original Message ----
> From: "david@..." <david@...>
> To: users@...
> Sent: Wednesday, April 23, 2008 1:24:05 PM
> Subject: RE: [dwr-user] signatures help
>
> 1) Your Java method expects a Map not an Array.  To send a map you need to
> send a JavaScript hash i.e {}, not a JavaScript array.
> var sendThisToSever = {};
> sendThisToServer["key1"] = "value1"
>
> or:
> var sendThisToServer = new Object();
> sendThisToServer.key1 = "value1";
>
> 2) You do not need signatures since your map only contains Strings.  That
> is just a warning message.  It is letting you know that DWR is assuming
> that the contents of the Map  are Strings which in your case is correct.
>
> Original Message:
> -----------------
> From: tyju tiui jckdnk111@...
> Date: Wed, 23 Apr 2008 10:19:46 -0700 (PDT)
> To: users@...
> Subject: [dwr-user] signatures help
>
>
> Hi,
>
> I'm having trouble sending a remote array of strings to a DWR-exposed
> method which expects a Map.
>
> js:
> var params = { 'myArr':["a", "b", "c"] };
>
> java:
> public class ParamActions{
>     public static boolean storeParams(Map params){
>         if(params.get("myArr").getClass().getClass().equals(Class.forName("[
> Ljava.lang.String;"))){
>             return true
>         }else{
>             return false;
>         }
>     }
> }
>
> When invoked by DWR, the java code always evaluates to false since the
> Object returned by params.get("myArr") is a String and not a String[].
> I found the following bug report describing a similar problem:
> http://getahead.org/bugs/browse/DWR-96
> It says the problem has been fixed in version 3M2 ... is this stable enough
> to use?
>
> Also, I see some warning in the DWR log talking about "Missing type info
> for storeParams(1<0>). Assuming this is a map with String keys. Please add
> to <signatures> in dwr.xml".
>
> I added the following to my dwr.xml but I'm still getting the errors:
>
> ...
> </allow>
>   <signatures>
>     <![CDATA[
>         import java.util.Map;
>         import test.dwr.ParamActions;
>         ParamActions.storeParams(Map<String,[Ljava.lang.String;>);
>     ]]>
>   </signatures>
> </dwr>
>
> I'm hoping if I can get the signatures section setup correctly then maybe
> my String[] will start magically working.
>
> Thanks,
>
> Ty
>
>
>
>       ______________________________________________________________________
> ______________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>
> --------------------------------------------------------------------
> mail2web.com – Enhanced email for the mobile individual based on
> Microsoft®
> Exchange - http://link.mail2web.com/Personal/EnhancedEmail
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>       ______________________________________________________________________
> ______________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>
> --------------------------------------------------------------------
> mail2web LIVE – Free email based on Microsoft® Exchange technology -
> http://link.mail2web.com/LIVE
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>       ______________________________________________________________________
> ______________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>
> --------------------------------------------------------------------
> mail2web.com – Enhanced email for the mobile individual based on Microsoft®
> Exchange - http://link.mail2web.com/Personal/EnhancedEmail
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>       ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: RE: signatures help