I think I need some help with something more basic than I realize...
The idea here is that my form has checkboxes named tickets[] When flow gets it, the toString() gives me 2,5,6 or what ever the values are. basically this function will build the IN sql clause (I know this is very hacky, but I am against a noon-type deadline)
The problem is I can't seem to check if it is null (No boxes checked) without a nullpointer exception. Which seems really irritating.. I want to TEST if it is null.
I don't see an attempt at a null check below - perhaps you took it out? But without seeing it, are you certain you did "== null" or "!=null" instead of (assignment) "= null"? Also, I presume you tested tickets right after var tickets = cocoon.request.get("tickets[]"); and not after the attempt to call toArray() (which would be too late).
var tickets = cocoon.request.get("tickets[]");
if (tickets == null) {
// Handle no tickets here
}Throws an NPE? If so, what is the stacktrace?
Geoff
Same thing to check if it contains a _single_ item. I have a try/catch to find the nullpointer... but of course when it has a single item it catches it too.
So in short:
How do I test if tickets has no elements? How do I check if tickets has one element to skip the for block?
Help :S
function do() { var tickets = cocoon.request.get("tickets[]"); try{ var s = "tickets.id IN (";
tickets = tickets.toArray();
for (var i = 0; i < tickets.length; i++) { tickets[i] = "'" + tickets[i] + "'"; if (i != "0") { s = s + "," + tickets[i]; } else { s = s + tickets[i]; } }
var s = s + ")"; print(s); cocoon.request.setAttribute("sql", s); cocoon.sendPage("postInvoice.xsp"); } catch(Exception) { print("Exception Occured"); cocoon.sendPage("fail.xml",{error: "Please Select Some Tickets."}); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
