cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Johnston" <>
Subject Re: Java and JavaScript in Cocoon app
Date Mon, 24 Oct 2005 22:31:12 GMT
What are you using on the server-side to process the request and build the
SQL?  Sitemap actions?  I'm assuming it's not Flowscript or JavaFlow since
you're using such an old version of Cocoon.

I don't think the JavaScript you describe is going to be of much use to
you; IIUC the JS you're talking about is client-side (as opposed to
server-side JS which later versions of Cocoon use for handling flow). 
Since it's client-side it therefore cannot execute code on the server
directly.  (LiveConnect would only allow your JS to talk to a client-side
Java applet embedded in your page, not the Java code on the server.)

What you need to do instead is in your server-side Java code that handles
the request, get the request parameters sent by the HTML checkboxes; this
is the request.getParameterValues("exclusions") you asked about, and
"exclusions" should match the name="" attribute of the checkboxes.  The
Java array returned by that method consists of the values of the
checkboxes that were checked by the user.

Am I on the right track at all here?  Let me know if I'm not understanding
your situation; it feels a bit odd explaining basic concepts like request
parameters (these concepts are not unique to Cocoon by the way, and are
usually already prerequisite knowledge for people working with web apps)
so I'm sorry if I'm just misunderstanding you and telling you stuff you
already know.


>>it builds [in Javascript] an array of checkboxes checked
>>called valueArray, which is not used now).
> Correction: actually, it seems that there is an attempt
> in the existing code to pass Javascript array to Java:
> onsubmit="if(this.inclusions)excludes.value=getCheckedValues(inclusions,true);return
> true;"
> Interestingly, "inclusions" is a name of all checkboxes in XSL
> page. But on Java side it doesn't use "inclusions", "excludes"
> or "valueArray", but uses:
> String [] exclusions = request.getParameterValues("exclusions");
> - I don't see where request parameter "exclusions" is coming
> from;
> - later instead of that array exclusions[] they pass NULL to the
> method which is supposed to create SQL based on that.
> I checked a few Javascript books, and it looks like one has to
> use LiveConnect technology to use JavaScript variables in Java,
> that requires "import netscape.javascript.*" package.
> There are no such imports in the code.
> Are there other ways to use JavaScript vars in Java ?
> What does "(this.inclusions)" means in
> "if(this.inclusions)excludes.value=getCheckedValues(inclusions,true);return
> true;" ?
> Is that a sort of casting ?  Passing array from JS to Java ?
> Is that a legitimate way to pass variables JS->Java ?
> Please advise.
> Thank you in advance,
> Oleg.
> --- Oleg Konovalov <> wrote:
>> Hi,
>> I am trying to enhance somebody's Cocoon 2.0.4 application
>> (tons of XSL and XML, Java and a bit of Javascript).
>> On my page there is a bunch of checkboxes (defined in XSL),
>> and based on which of them user selects,
>> it supposed to dynamically build SQL stament
>> (in Stored Procedure with flags as parameters),
>> called from Java.
>> There is a little bit of manipulation on these checkboxes
>> currently done in JavaScript (e.g. it builds an array
>> of checkboxes checked called valueArray, which is not used
>> now).
>> I think, I can use that JavaScript array,
>> but not sure how to access it from Java. How ?
>> something with LiveConnect (have no experience with that),
>> any sample ?
>> Would that be a normal thing to do in Cocoon application
>> or is there a better and easier way (since XSL will generate
>> Java bytecode) ?
>> Sorry for the newbie question.
>> Thank you in advance,
>> Oleg.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message