cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sonney <>
Subject Re: esql with Vars, or esql diff of the moment...
Date Mon, 25 Sep 2000 19:51:31 GMT
On Mon, 25 Sep 2000, Donald Ball wrote:
> I fail to see what this patch buys you, except making the code more
> complex. Can you explain?

Sure, why not?

Without the patch, the only way to put Java variables was to either
declare a "global" with <xsp:logic> (or my xsp:variable patch), or not use
variables at all - limiting the quesries somewhat. For example, the
following :

<!-- Stupid simple example -->
String test_query = "Select * from bob_table where bob_id = 1";
<!-- esql setup params go here -->
<!-- esql result processing goes here -->

would result in a "variable test_query not found" error message durring
compelation. Well, yeah, as test_query was outside the esql session
function. This is something that people had been lamenting on this list
since you released esql. The solutions were to (a) not use java vars &
expresions in esql:queries (which ahs met with some reluctance), (b) use
globals, or (c) patch esql. 

I opted for (b) last week, but the thread safety issue could be a big
problem for the one application i'm working on. So, fresh this morning
from a weekend away from the code, I opted for (c).

The solution I've given with this patch *ISN"T* a major code change. It
only does the following :

1) Moves processing of the esql:query element prior to (and outside) the
genration of the esql method,
2) Adds *1* variable to the method call, and 
3) Sets the value of _esql_session.query to the passed variable

Now this doesn't seem all that complex to me. But it does add a bit of
missing functionality (if the list archives of the past week or two are to
bebelived) to the esql logic sheet that wasn't there before. 

After the patch, I can pre-process my query string all I want - do things
like :

String var1 = <request:get-parameter name="var1"/>;
String var2 = <request:get-parameter name="var2"/>;
String eqsl_query_test = "select test_data from test_table";

// conditional processing to add var1 & var2 to the query based on
// goes availability here, like testing for null, etc, etc


<!-- esql setup params go here -->
<!-- esql result s go here -->

This, in my mind, is a lot easier to deal with (and a lot less hassle to
implement - since I did it for you *grin*) than the "estra elements to
pass vars to esql since we can't use xsp:expr" ideas I saw last week. 

Does this make it any clearer on why I did it, and what you get? Feel free
to tell me if not. Heck, feel free to tell me it's a Really Bad Idea (tm),
and I'll work on a better one. But I figure this one :

(a) is easy to implement,
(b) requires no additional documentation,
(c) requires no extra elements or attributes in the logic sheet


| Kevin Sonney |
| Systems Programmer |

View raw message