You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joose Vettenranta <jo...@iki.fi> on 2004/03/18 12:31:36 UTC

Accessing request-params from java-object called by flowscript

Hi again,

I have a java object which wants to know 5 value sent by browser.

In flow script I can call
cocoon.request.get("param1");
cocoon.request.get("param1");
...
cocoon.request.get("param5");

But because that is not always the case and only java object knows how 
many of those are required..

So

is it possible to pass that cocoon.request object to java object, so in 
that java-object I could do like

class javaObject {
  String param1;
  String param2;
  String param3;
  String param4;
  String param5;

  void getParams (object cocoonRequest) {
   param1 = cocoonRequest.get ("param1");
   param2 = cocoonRequest.get ("param2");
   param3 = cocoonRequest.get ("param3");
   param4 = cocoonRequest.get ("param4");
   param5 = cocoonRequest.get ("param5");
  }
}

so in flowscript I could just call

my.own.javaObject.getParams (cocoon.request);

Then when new javaObject's are created, I just make that class 
accessible for javascript and it works, no need to change flowscript 
itself. And If I save object-data in a LList, I can do walk through on 
those components and ask the to get those params...

- Joose

--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


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


Re: Accessing request-params from java-object called by flowscript

Posted by Peter Velychko <v_...@ukr.net>.
Hello Joose,

cocoon.request in javascript corresponds to the
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon$FOM_Request class.
FOM_Request has the method

public Object get(String name) {
    return request.get(name);
}
where "request" is of the type
"org.apache.cocoon.environment.Request".
So the following should work
Packages.my.own.javaObject.getParams (cocoon.request);

Another way is to process request in javascript: it is also
programming language :)

JV> Hi again,

JV> I have a java object which wants to know 5 value sent by browser.

JV> In flow script I can call
JV> cocoon.request.get("param1");
JV> cocoon.request.get("param1");
JV> ...
JV> cocoon.request.get("param5");

JV> But because that is not always the case and only java object knows how 
JV> many of those are required..

JV> So

JV> is it possible to pass that cocoon.request object to java object, so in 
JV> that java-object I could do like

JV> class javaObject {
JV>   String param1;
JV>   String param2;
JV>   String param3;
JV>   String param4;
JV>   String param5;

JV>   void getParams (object cocoonRequest) {
JV>    param1 = cocoonRequest.get ("param1");
JV>    param2 = cocoonRequest.get ("param2");
JV>    param3 = cocoonRequest.get ("param3");
JV>    param4 = cocoonRequest.get ("param4");
JV>    param5 = cocoonRequest.get ("param5");
JV>   }
JV> }

JV> so in flowscript I could just call

JV> my.own.javaObject.getParams (cocoon.request);

JV> Then when new javaObject's are created, I just make that class 
JV> accessible for javascript and it works, no need to change flowscript 
JV> itself. And If I save object-data in a LList, I can do walk through on 
JV> those components and ask the to get those params...

JV> - Joose

JV> --
JV> "Always remember that you are unique, just like everyone else!"
JV> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


JV> ---------------------------------------------------------------------
JV> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
JV> For additional commands, e-mail: users-help@cocoon.apache.org

-- 
Best regards,
Peter Velychko                            
v_peter@ukr.net


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