Hi,
Here's something I wrote to scan any and all fields on a page and pick up
qbe operators and values.  Sorry I don't have time to go through it and
remove references to my local class library.  Maybe you can get something
from it, particularly the way that operators and values are retrieved from
the fields that are returned.

-- Curt Springer, Team ND 


//**************************************************************************
**************
     /**
     * An event which is triggered in edit mode when the user clicks on the
"Search"
     * button after specifying selection criteria.  This should be tied to
a button on the page
     *<br><br>
     */

//**************************************************************************
**************
     public final int onSearchWebEvent( String args[] )
     {
          int command = PROCEED_WITH_BUILTIN_HANDLING;
          try
             {
//CSpLog.send(this, CSpLog.ERROR, "onSearchWebEvent: calling restore");
              restorePageValues();

            //get the web vars, needed by qbe controls:
            Hashtable webvars = CSpider.getWebVars();

            //start by clearing any existing criteria on the row container
            //note:  this leaves foreign key criteria intact
            _crc.clearDynamicCriteria();


            columnloop:
            for (Enumeration e =
_topsectionbinding._bindings.elements();e.hasMoreElements();)
                {
                 ColumnBinding cb = (ColumnBinding) e.nextElement();


                //CSpLog.send(this, CSpLog.ERROR, "beginning field:
"+cb._displayfield.getName());

                if (cb._displayfield instanceof CSpStaticText)
                {
                    //don't try to get qbe values from static text fields
                    continue columnloop;

                  } //if (cb._displayfield instanceof CSpStaticText)

                CSpValue value =cb._displayfield.getValue();
                Object objvalue = NetDynamicsUtility.convertCSpValue(this,
value);



                //CSpLog.send(this, CSpLog.ERROR, "the value of the field
is "+objvalue);

                //if field was not displayed, or no qbe value specified, skip
               if (NetDynamicsUtility.blankObject(this, objvalue))
                     {
                    //CSpLog.send(this, CSpLog.ERROR, "blank/null value,
skip field");
                    continue columnloop;
                }//if (NetDynamicsUtility.blankObject(this, objvalue))

              //see if upshifting or downshifting required
              switch (cb._inputformat)
              {
                case SectionBinding.INPUT_UPSHIFT:
                    objvalue = objvalue.toString().trim().toUpperCase();

                    break;  //case SectionBinding.INPUT_UPSHIFT:

                case SectionBinding.INPUT_DOWNSHIFT:
                    objvalue = objvalue.toString().trim().toLowerCase();

                    break;  //case SectionBinding.INPUT_UPSHIFT:

              }//switch (cb._inputformat)


                //CSpLog.send(this, CSpLog.ERROR, "the value of the field
is "+objvalue);



                switch (cb._bindtype)
                {
                case HMSDisplayField.BIND_QBE_COLUMN:
                //CSpLog.send(this, CSpLog.ERROR, "binding
type=BIND_QBE_COLUMN");

                //now get any QBE info on this field.  There should be
some, but, if none
                //found, just skip to the next

                CSpQBEControl qbecontrol = cb._displayfield.getQBEControl();
                if (qbecontrol==null)
                {
                 //CSpLog.send(this, CSpLog.ERROR, "qbe control is null,
skipping field");
                 continue columnloop;
                }//if (qbecontrol==null)

                qbecontrol.readWebValues(webvars);

                //set criteria based on query type
                switch (qbecontrol.getQueryType())
                {
                case CSpQBEControl.NO_QUERY_TYPE:

                //CSpLog.send(this, CSpLog.ERROR, "query type is
NO_QUERY_TYPE, skipping field");
                    continue columnloop;


                case CSpQBEControl.IMPLICIT_QUERY_TYPE:
                //CSpLog.send(this, CSpLog.ERROR, "query type is IMPLICIT");


                      //CSpLog.send(this, CSpLog.ERROR, "single criterion
value is not blank, will be set");
                  if (!(objvalue instanceof Number))
                  {
                    //CSpLog.send(this, CSpLog.ERROR, "implicit string
equals operator will be used");
                    _crc.addDynamicCriterion (
                                    cb._colpos,
                                    HMSGeneralSelect.HMS_EQUAL_TO_STR_OPERATOR,
                                    objvalue
                                    );
                              }//if (!(objvalue instanceof Number))

                  else
                  {
                    //CSpLog.send(this, CSpLog.ERROR, "implicit int equals
operator will be used");
                    _crc.addDynamicCriterion (
                                    cb._colpos,
                                    HMSGeneralSelect.HMS_EQUAL_TO_INT_OPERATOR,
                                    objvalue
                                    );
                              }//else




                    break;  //case CSpQBEControl.IMPLICIT_QUERY_TYPE:



                case CSpQBEControl.EXPLICIT_QUERY_TYPE:
                //CSpLog.send(this, CSpLog.ERROR, "query type is EXPLICIT");

                int hmsexcriterionoperator=0;
                try
                {
                hmsexcriterionoperator
=NetDynamicsUtility.getHMSCriterionOperator
                                            (this, 
qbecontrol.getSelectedQueryOperator());
                            }//try
                            catch (Exception ndex)
                            {
                             //CSpLog.send(this, CSpLog.ERROR,
                             //"error caught calling 
NetDynamicsUtility.getHMSCriterionOperator: "
                            // + ndex + ", will skip this field");
                             continue columnloop;

                            }//catch (Exception ndex)

                            //CSpLog.send(this, CSpLog.ERROR, "the HMS criterion 
operator="+
                             // hmsexcriterionoperator);

                    if (!qbecontrol.betweenQueryOperator())
                    {
                   // CSpLog.send(this, CSpLog.ERROR, "this is not a
'between' operator");
                      //only one value argument


                     // CSpLog.send(this, CSpLog.ERROR, "single criterion
value is not blank, will be set");

                    _crc.addDynamicCriterion (
                                    cb._colpos,
                                    hmsexcriterionoperator,
                                    objvalue
                                    );



                    }//if (!qbecontrol.betweenQueryOperator())
                    else
                    {
                       // CSpLog.send(this, CSpLog.ERROR, "this IS a
'between' operator");

                      Object objmaxvalue
=NetDynamicsUtility.convertCSpValue(this, qbecontrol.getMaxValue());

              //see if upshifting or downshifting required
              switch (cb._inputformat)
              {
                case SectionBinding.INPUT_UPSHIFT:
                    objmaxvalue = objmaxvalue.toString().trim().toUpperCase();

                    break;  //case SectionBinding.INPUT_UPSHIFT:

                case SectionBinding.INPUT_DOWNSHIFT:
                    objmaxvalue = objmaxvalue.toString().trim().toLowerCase();

                    break;  //case SectionBinding.INPUT_UPSHIFT:

              }//switch (cb._inputformat)


                      //CSpLog.send(this, CSpLog.ERROR, "max
value="+objmaxvalue);

                       // CSpLog.send(this, CSpLog.ERROR, "at least one
range criterion nonblank, will set");

                      //range argument (e.g. between a and b)
                    _crc.addDynamicCriterion (
                                    cb._colpos,
                                    hmsexcriterionoperator,
                                    objvalue,
                                    objmaxvalue
                                    );


                    }//else

                    break;  //case CSpQBEControl.EXPLICIT_QUERY_TYPE:

                }//switch (qbecontrol.getQueryType())




                break;  //case HMSDisplayField.BIND_QBE_COLUMN:

                default: //diagnostic only
                //CSpLog.send(this, CSpLog.ERROR, "binding type is NOT
BIND_QBE_COLUMN");
                }//switch (cb._bindtype)

                }//for (Enumeration e =
_topsectionbinding._bindings.elements();e.hasMoreElements;)

        _crc.serializeToSession();

                _browsepage.load();






          } // try
          catch (Exception ex)
          {
               writeLog ( this, CSpLog.ERROR, "onSearchWebEvent" + ex );
               command = STOP_PROCESSING;
          } // catch
          return (command);
     }     // public final int onSearchWebEvent( String args[] )






At 03:17 PM 5/19/99 -0800, [EMAIL PROTECTED] wrote:
>Hi,
>
>I have a Search page with a combobox with some values from a DO.
>Currently this ComboBox has different Query operators. I need to
>bind this Combobox to different DOs based on certain conditions.
>So I call getDisplayFieldValue and add the criterion to the 
>correct DO. How do I catch the Query Operator that the user has
>selected before adding the critereon to the DO??
>
>My code looks something like this - 
>CSpSelect drDo = (CSpSelect) CSpider.getDataObject("do1");
>String whereDRStr = "";
>whereDRStr = "dradmin.table1.field2 " + (CSpDisplayField)
getQBEControl("cmbCDE") + " \"" +
getDisplayFieldValue("cmbCDE").stringValue() + "\"";
>drDo.addDynamicCriterion("field2", CSpSelect.QBE_CRITERIA_TYPE, 
>new CSpString(whereDRStr));
>
>As you can see, I am trying to call the getQBEControl method within my
select string but I am not able to complile this succesfully let alone run
and test it.  
>                               
>Thanks in advance for all your help.
>
>Nilima Desai 
>408-970-2236
>_________________________________________________________________________
>
>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]
> 
_________________________________________________________________________

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]

Reply via email to