the way I do it is create in an <xsp:logic> block my WHERE clause (as a String), using
the <xsp:get-parameter name="type"/> and such, and then use an <xsp:expr>where_string</xsp:expr>
in the esql statement.
<xsp:logic>
String mytype = <xsp:get-parameter name="type"/>;
String where_string = "WHERE";
if ( mytype!=0 && !mytype.startsWith("--") ) {
where_string += "TYPE == " + mytype;
}
//other clauses
if ( where_string.equals( "WHERE" ) ) {
/ if no options are selected.
where_string == "";
}
</xsp:logic>
// Fast forward to
<esql:query>
SELECT something FROM foo <xsp:expr>where_string</xsp:expr>
ORDER BY bar DESC;
<esql:query>And then use the results.
This may not be exceptionally smart, and to be honest I used somewhat more logic in the
creation of my where string. But if you know java creating a string is not that hard:) I think
especially your startsWith constraint requires imho somehat java (or javascript) logic.
Leon
Rudi Strasser wrote:
On Wednesday 18 February 2004 19:31, [EMAIL PROTECTED] wrote:
Hi all,I am not sure if this is excatly what you are looking for, but you can fill in the respective selection list in the form definition:
I have build several xsp:pages which contain forms holding textboxes and dropdownboxes. The dropdownboxes are filled with values from a query.
I will explain my problem with a real life example. The form offers a way to search/filter for, let's say, trouble tickets. A trouble ticket is of a certain type (incident, change or problem). It also has a severitycode (low, middle, heavy) and it has a description for example.
Suppose I have a form with two dropdownboxes (ddb) and one textbox (tb)
*ddbType has following options : (SELECT DISTINCT TYPE FROM TROUBLES) -- any type incident change problem *ddbSeverityCode has following options: (SELECT DISTINCT SEVERITYCODE FROM TROUBLES) -- any severity code low middle heavy *tbDescription (is empty)
Now i want depending of the userinput to run following query :
String MyDynamicQuery = "SELECT TROUBLEID FROM TROUBLES " <!-- conditional If any parameters are filled in --> + " WHERE " <!-- conditional if ddbType contains valid value (this means not empty and not starts with '--' --> TYPE = ? <!-- conditional if ddbType contains valid value (this means not empty and not starts with '--' --> <!-- conditional if ddbSeverityCode contains valid value (this means not empty and not starts with '--' --> SEVERITYCODE = ? <!-- conditional if ddbSeverityCode contains valid value (this means not empty and not starts with '--' --> <!-- conditional if tbDescription contains valid value (this means not empty --> DESCRIPTION LIKE %?% <!-- conditional if tbDescription contains valid value (this means not empty --> <!-- conditional If any parameters are filled in -->
Is it possible to use woody and to use some binding mechanism to set the parametrized WHERE statements in a clever way? Anyone working on something similar?
<wd:field id="parfilter">
<wd:label>Filter</wd:label>
<wd:datatype base="string"/>
<wd:on-value-changed>
<javascript>
var value = event.source.value;
var parnamewidget = event.source.parent.getWidget("parname");
parnamewidget.setSelectionList("cocoon:/parameters?mask=" + value);
</javascript>
</wd:on-value-changed> <wd:help>
Enter a regular expression pattern.
</wd:help>
</wd:field>
<wd:field id="parname" required="true">
<wd:label>Parameter</wd:label>
<wd:datatype base="string"/>
<wd:selection-list src="cocoon:/parameters" dynamic="true"/>
</wd:field>
Here, the parname selection options will be reconfigured every time 'parfilter' changes its value (it is demomstrated in the 'car' example of woody). I am performing DB to generate the respective values. I think this feature is very powerful and might solve your problem.
/Rudi
Robby Pelssers
---------------------------------------------------------------------
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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
