This is a section of code from a 4.00 project. for the search button
using combo box and listbox
All works except session objects.
Peter Cheung
Team NetDynamics
//[[SPIDER_EVENT<onSearchWebEvent>
public int onSearchWebEvent( String args[] )
{
int command = doQBE(args);
try
{
dos = (CSpMultiSQL)
CSpider.getDataObject("doAll");
CSpValue dfxv =
getDisplayFieldValue("combo_dfx");
if (dfxv.stringValue().length() > 0)
{
dos.addDynamicCriterion ( "main_No",
CSpCriteriaSQLObject.BEGINS_WITH_STR_OPERATOR,dfxv);
}
CSpListBox listBox = (CSpListBox)
getDisplayField("main_Category");
String category = new String();
String whereClause = new String();
// Loop through the list of selected items
int i = 0;
boolean first = true;
boolean selected = false;
for ( i = 0; i <
listBox.getSelectedList().size(); i++)
{
CSpSelectable select = (CSpSelectable)
listBox.getSelectedList().elementAt(i);
category = ((CSpValue)
select.getValue()).stringValue();
if (category.length() > 1)
{
selected = true;
if (first)
{
whereClause = "main.Category =
'" + category + "'";
first = false;
}
else
{
whereClause = whereClause + " OR
" + "main.Category = '" + category + "'";
}
}
}
if (selected)
{
// the ( category=a OR category=b ) is needed
whereClause = "(" + whereClause + ")" ;
dos.addDynamicStrCriterion
("main_Category", whereClause);
}
whereClause = dos.getDynamicCriteria();
CSpider.putSessionObject("SQLStr", new
CSpString(whereClause));
dfx.debug( " SQLStr = " +
CSpider.getSessionObject("SQLStr").stringValue()) ;
String strOrder;
if (getDisplayFieldValue("orderBy").intValue()
== 1)
{
strOrder = new String("main.Category
asc, main.T desc");
dos.setSelectOrderStr(strOrder);
}
else
{
strOrder = new String("main.T desc");
dos.setSelectOrderStr(strOrder);
}
if (command == PROCEED_WITH_BUILTIN_HANDLING)
{
command = doAction(args);
}
CSpider.putSessionObject("OrderStr", new
CSpString(strOrder));
dfx.debug( " OrderStr = " +
CSpider.getSessionObject("OrderStr").stringValue()) ;
// update the search count
dos2.clearDynamicCriteria();
dos2.addDynamicCriterion ( "stats_item_name",
CSpCriteriaSQLObject.EQUAL_TO_STR_OPERATOR,
new CSpString ("NumberSearched"));
dos2.executeSelect();
int searchCount = dos2.getValue (0,
"stats_item_value").intValue();
dos2.clearAllValues ();
dos2.setValue ("stats_item_value", new
CSpInteger (searchCount + 1));
dos2.executeUpdate();
}
catch (Exception ex)
{
// send any exceptions to the Log
CSpLog.send (this, CSpLog.ERROR,
"onSearchWebEvent :
Unexpected Exception caught (" +
ex + ")");
}
// bug in 4.0 for new CSpboolean()
try
{
CSpider.putSessionObject("FromOtherPage", new
CSpBoolean("false"));
}
catch(Exception ex)
{}
CSpider.putSessionObject("FristRecordUpdateProject", new
CSpInteger(0));
return(command);
}
//]]SPIDER_EVENT<onSearchWebEvent>
> -----Original Message-----
> From: Eric Weiss [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, February 26, 1998 9:19 AM
> To: '[EMAIL PROTECTED]'
> Subject: [ND] Ad Hoc Data Object
>
> NetD Newbie....
>
> Does anyone have an examples of any custom ad hoc query pages that
> dynamicly build the SQL based on several pull down boxes? I need to
> build
> an ad hoc page that the "canned" Search Page can't handle and would
> appreciate any guidence or examples.
>
> Thanks,
> Eric Weiss
> [EMAIL PROTECTED]
>
> ______________________________________________________________________
> ___
>
> Helpful addresses for the forums... http://forums.netdynamics.com
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]