How do I enable the update, but not insert

Hello

I have a LOV (sports say) and a checkbox (say flag). The user must select at the time of the creation of record.

for the first time when a user selects a sport in LOV, the check box will be disabled.

the user should not be able to create a record with the same sport, unless the existing record indicator is checked.

To do this, I created a display criteria in the PVO of the same table, linking the LOV and the flag.

created GOES in the EO with parameter flag = 'n'.

then he created a validator for the entity using the method.

inside the method, I ran the query'S and used the following condition.

public boolean validatesport() {}

this.getSportsChoicePVO () .executeQuery ();

Set of lines rs = this. getSportsChoicePVO ();

If (RS. GetRowCount() > 0)

Returns true;  

on the other

returns the value false;       

}

What happen to a sport, it's... If there is no record with indicator = N, its allowing to insert the record.

but as he tried to update the indicator = Y the number be 1 and its not allowing to update.

If I put the count > 1, its to insert the same record with indicator = N, which should not happen twice.

Please suggest what I can do,

whereas when there is already a record, he should be able to update and no insert with the same choice.

Hi Timo,

Thanks.I was able to reach my need of the following logic in the validator of the method.

When count = 0, this means that the user inserts for the first time.

When count = 1, if the entity is changed, it means that it will update and therefore allowed.

public boolean validatesport() {}

this.getSportsChoicePVO () .executeQuery ();

All lines rs = this.getSportsChoicePVO ();

If ((RS. GetRowCount () == 0) | ((getEntityState () == Entity.STATUS_MODIFIED & rs.getRowCount () == 1))

Returns true;

on the other

Returns false;

}

Tags: Java

Similar Questions

Maybe you are looking for