Re: Problem with ResultEvent and Array

Ian Pojman <[email protected]>
Newsgroups gmane.comp.java.openamf.user
Message-ID <[email protected]>
for me, arrays come back as an array as an (actionscript) Object,
remember AS objects are glorified hash maps, so the result comes back
as a table with number->value pairs,
ie
{1:someObject, 2:someObject, 3:someObject}

taken a look in the debugger?
/ian


On Mon, 6 Dec 2004 12:39:44 -0500, Leif Wells <[email protected]> wrote:
> Greetings All,
> 
> I am having a problem with receiving an Array from OpenAMF. Actually,
> the problem isn't in the receiving, but in the giving. Somehow, when
> receiving an Array from Java and changing items in that Array and then
> returning that Array, Java thinks that the returning Array is an
> ASObject, which results in a NullPointerException in our code. We've
> located that the problem lies at the receiving of the initial Array
> and how it is being casted in Flash. Flash clearly believes this item
> to be an Array (it has toString(),  and length functionality).
> 
> This may be a result of going to the new ActionScript 2.0 components.
> Using PendingCall and RelayResponder and ResultEvent could be
> confusing me (and thus Java). Any insight into this would be
> appreciated.
> 
> We are returning an Array this way:
> 
> //code has been cleaned for public consumption
>         public List getQuestionAnswers(String questionId)
>         {
>                 List answerList = new ArrayList();
> 
>                 if (validateRequest())
>                 {
>                         // request is valid
>                         QuestionController questionController = new
> QuestionController(request,response);
>                         answerList = questionController.getQuestionAnswers(questionId);
>                 }
> 
>                 Iterator listItr = answerList.iterator();
>                 while (listItr.hasNext())
>                 {
>                         AnswerValue loopAnswer = (AnswerValue)listItr.next();
>                 }
> 
>                 return answerList;
>         }
> //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> OK, so, nothing unusual there. We are catching this in Flash like this
> (please note the in-line comments)
> 
>         //We are using AS 2.0 here, but we cannot type our resultEvent(the "re")
>         //When we do so, we either get a compile error in Flash or it simply
> doesn't work
>         //If I cast the re as an array (re:Array), it doesn't work either
>         public function getQuestionAnswersResult(re):Void{
>                 //at this point, re.result is an Object, not an array.
>                 //Or, at least when I return the Array to Java later, Java thinks
> that it is an ASObject
>                 answers_array = re.result;
>                 //
>                 //This is what I am having to do to avoid the actual Array becoming
>                 //an Object to Java
>                 temp_answers_array = answers_array.slice(0, answers_array.length);
>                 answers_array = temp_answers_array;
> 
> }
> //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Mind you, this works for now. But it deeply disturbs me that it
> doesn't work correctly. Or at least not the way I am expecting.
> 
> Is ResultEvent expecting that result be an Object every time? Is that
> what is happening? Are my Java guys *supposed* to wrapping the result
> in an Object? That sounds crazy!
> 
> Any ideas?
> 
> Thanks,
> 
> Leif
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Openamf-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openamf-user
>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.