XXX code tags in generated FormData classes [message #1713075] |
Fri, 30 October 2015 15:56 |
Samuel Messages: 22 Registered: January 2012 |
Junior Member |
|
|
I have two questions related to XXX code tags in generated form data classes.
(1) I have a form with a smartfield that has a LocalLookupCall configured.
The form data of this form then gets the following comment:
/**
* XXX not processed ValidationRule(lookupCall)
* 'MyLookupCall.class' is not accessible from here.
* at ors.eclipse.scout.basteleien.client.TestForm.MainBox.TestField#getConfiguredLookupCall
*/
The comment is correct: the field validation for this field cannot be performed on server side because the server does not know the local lookup call.
As we have the policy of not having any TODOs, FIXMEs or XXXs in the productive code, I want to get rid of the "XXX".
Possible solutions:
(a) Not including the field in the form data using the form data annotation "@FormData(sdkCommand = SdkCommand.IGNORE)" on thie field.
(b) Moving the local lookup call to the shared plugin.
Solution (a) is not an option for me since I need the value of the field on the server side.
Solution (b) would in my case indeed be an option.
Nevertheless, do you see other solutions (in case both solutions (a) and (B) are no option to the user)?
(2) I have a form with a post code field and a city field. The city field has the post code field as its master field.
The city field is an instance of an AbstractCityField (code template).
As the city field must know it's post code field, the AbstractCityField has an abstract method getConfiguredPostCodeField().
public abstract class AbstractCityField extends AbstractStringField {
protected abstract Class<? extends IValueField<?>> getConfiguredPostcodeField();
@Override
protected String getConfiguredLabel() {
return TEXTS.get("City");
}
}
Hence, each instance of an abstract city field must provide its post code field.
The method getConfiguredMasterField just returns the result of the method getPostcodeField.
The main box of my TestForm looks as follows:
@Order(10.0)
public class MainBox extends AbstractGroupBox {
@Order(20.0)
public class PostcodeField extends AbstractStringField {
@Override
protected String getConfiguredLabel() {
return TEXTS.get("Postcode");
}
}
@Order(30.0)
public class CityField extends AbstractCityField {
@Override
protected Class<? extends IValueField<?>> getConfiguredPostcodeField() {
return getPostcodeField();
}
@Override
protected Class<? extends IValueField> getConfiguredMasterField() {
return getPostcodeField();
}
}
}
The generated form data object for this form has the following comment in the method initValidationRules(...) of the City class:
/**
* XXX not processed ValidationRule(masterValueField)
* 'getPostcodeField()' is not accessible from here.
* at ors.eclipse.scout.basteleien.client.TestForm.MainBox.CityField#getConfiguredMasterField
*/
Again, I understand, that the FormData generator cannot determine the class of the master field at compile time.
Nevertheless, for the same reasons as above, I want to get rid of the XXX code tag.
Possible solution:
Include both the postcode field and the city field in the code template (and write something like an "AbstractPostcodeCityBox")
This solution is not an option in my project.
Can you suggest other solutions?
Possible solutions:
(1) One could implement an annotation on a form field that controls if validation rules for this field are included into the form data class. Something like "@InputValidation(value = IGNORE)".
(2) The above annotation could also be placed on the getConfiguredXxx methods. An annotation on the method getConfiguredMaxLength would e.g. inhibit the rule on the maximal length of a string field in the form data. Consequently, this annotation on the method getConfiguredMasterField wouled inihibit the fule for the master field in hte form data.
Cheers, Samuel
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03910 seconds