Hello,
I'm working on a Search web form and I'm using OJB to retrieve data from my database.
I have three criteria on my form:
- name (String)
- dhcp (boolean)
- status (int)
The user has 2 choices: enter a data in the form fields or not.
I want to retrieve:
-> all (no criteria in the query) if there is nothing in the form field.
-> the data considering the criteria entered in the form field if there is one.
The code is
----code----
Criteria crit = new Criteria();
crit.addEqualTo("name", this.getName());
crit.addEqualTo("dhcp", new Boolean(this.getDhcp()));
crit.addEqualTo("status", new Integer(this.getStatus()));
Query query = new QueryByCriteria(Workstation.class, crit);
Collection toBeEdited = broker.getCollectionByQuery(query);
...
----code----
A problem occurs when there are nothing in the form fields, then OJB try to find data
that have nothing in their fields instead of all the data.
Is there an "OJB" solution to do:
if field = ""
then field = "%"
Thanks
Sylvain
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]