Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » AbstractComposerAttribute.getConfiguredStatement
AbstractComposerAttribute.getConfiguredStatement [message #579709] Tue, 06 April 2010 12:22 Go to next message
Alex Schroeder is currently offline Alex SchroederFriend
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland

Hi dev team! :)

I'm looking at a search form for "persons" that can be either active or inactive. The search form itself has an Active field with three states: Yes, No, All. The SQL code is created using execAddSearchTerms.

public void execAddSearchTerms(SearchFilter search){
search.addWhereToken("P.ACTIVE IN(0,1)");
else if(getValue()==0){
else if(getValue()==1){
search.addWhereToken("P.ACTIVE=1 AND C.ACTIVE IN (-1,1)");
+"="+getSelectedButton().getLabel().replace("&", ""));

That's cool and works.

At the same time, I have an advanced search tab using an AbstractPersonComposerField that inherits from AbstractComposerField. There, I have an attribute called Active using the Boolean code type. The SQL Statement is generated a bit differently, unfortunately:

public String getConfiguredStatement(){
return "(<attribute>P.ACTIVE</attribute> "+
"AND <attribute>C.ACTIVE</attribute>) ";

And preliminary testing shows that showing the active or inactive persons shows a different result set depending on whether the standard Active attribute or the advanced search constraint is used.

My question is this: What's the exact effect of the attribute tag in an AbstractComposerAttribute.getConfiguredStatement?

What I need to do, I think, is to rewrite one of the two pieces to result in the same SQL as the the other piece such that there is no result set difference no matter what code is being used.
Re: AbstractComposerAttribute.getConfiguredStatement [message #579742 is a reply to message #579709] Tue, 06 April 2010 12:42 Go to previous messageGo to next message
Alex Schroeder is currently offline Alex SchroederFriend
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland

Well, it turns out that I no longer need the answer to the above question in order to solve my problem (the SQL based solution follows below), but I'm still curious.

And I'd love to know whether there are other magic tags to be used! :)

* This code mimics the PersonSearchForm.
* If the person is not active: P.ACTIVE=0 (and thus C.ACTIVE=C.ACTIVE is always true).
* If the person is active: P.ACTIVE=1 AND C.ACTIVE IN (-1,1).
public String getConfiguredStatement(){
return "(<attribute>P.ACTIVE</attribute> "+
" -1, C.ACTIVE))) ";
Re: AbstractComposerAttribute.getConfiguredStatement [message #580247 is a reply to message #579742] Thu, 08 April 2010 10:16 Go to previous message
Ivan Motsch is currently offline Ivan MotschFriend
Messages: 123
Registered: March 2010
Senior Member
Above is pre eclipse-scout code and also has legacy status.
Sql fragments on client side is not supported and not recommenden in applications.

For performing search and find processing logic based on search forms, eclipse scout also makes use of form data classes as in normal forms.
The above example search form PersonSearchForm has a form data PersonSearchFormData that can be passed to the back-end as search criteria set.

When used for example in the PersonTablePage, the following parts are normally of interest:
The SearchFilter object has the three properties
completed boolean if the search is complete e.g. valid to obtain search results
displayTexts list of strings of verbose description of the search elements
formData object containing the non-empty values of the form

When saved, the search form is automatically collecting all verbose search texts on the form fields
and calling execResetSearchFilter(...)

In the PersonSearchForm override the method execResetSearchFilter to set the form data to the search filter object:

protected void execResetSearchFilter(final SearchFilter searchFilter) throws ProcessingException{
PersonSearchFormData data=new PersonSearchForm();

The PersonTablePage populates its table using a back-end service call that directly delivers a data matrix (for simplicity here).
The only argument is the search filter (containing the form data).

protected Object[][] execLoadTableData(SearchFilter filter) throws ProcessingException{
Object[][] tableData=SERVICES.getService(IPersonProcessService.class).g etPersonTableData(filter);
return tableData;

The IPersonProcessService.getPersonTableData operation uses the search filter and retrieves the data from the data stores.
This might be using hibernate, eclipse link or direct jdbc access.
When using direct jdbc access there is a helper base class to easily create jdbc statement builders based on a form data.
We create a subclass PersonSearchStatementBuilder.
As in Alex's example the composer attribute "Active" is just mapped to a sql part and the three-state radio button "Active" is implemented as java code in the "buildeConstraintsFor" method override.

public class PersonSearchStatementBuilder extends FormDataStatementBuilder{

public PersonSearchStatementBuilder(ISqlStyle style){
//for each formdata inner type add a statement mapping
addStatementMapping(AbstractPersonComposer.ActiveAttribute,"( <attribute>P.ACTIVE</attribute> AND <attribute>C.ACTIVE</attribute>)");

protected void buildConstraintsFor(AbstractFormFieldData f){
Integer value=((PersonSearchFormData.Active)f).getValue();
addWhereToken("P.ACTIVE IN(0,1)");
else if(value==0){
else if(value==1){
addWhereToken("P.ACTIVE=1 AND C.ACTIVE IN (-1,1)");


The person service performing the search now simply has the code:

public class PersonProcessService extends AbstractService implements IPersonProcessService{


public Object[][] getPersonTableData(SearchFilter filter) throws ProcessingException{
PersonSearchFormData formData=(PersonSearchFormData)filter.getFormData();
PersonSearchStatementBuilder builder=new PersonSearchStatementBuilder(SQL.getStyle());;
"SELECT .... "+
"FROM ... "+
"WHERE ... "+


Previous Topic:AbstractComposerAttribute.getConfiguredStatement
Next Topic:Interested Parties
Goto Forum:

Current Time: Wed Feb 22 04:03:41 GMT 2017

Powered by FUDForum. Page generated in 0.04750 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software