Hello,

I fixed one of the problems. Can some one check in the fix?


1. Type mismatch: cannot convert from int/float/long to String

File: JSFCrudGuiJava.xpt -> «DEFINE itemLabel(String prefix) FOR
DomainObject -»

If a entity has only one attribute and it is not of type "String" , then the
"itemLabel" function generate not a String value, but e.g. expresion of type
Integer, Long, Float and it can't be cast to String. The solution is to
check the size of collentions and write ""+, when the size is one

Fixed function in JSFCrudGuiJava.xpt


«DEFINE itemLabel(String prefix) FOR DomainObject -»
«IF hasNaturalKey()-»
        «LET getAllNaturalKeyReference() AS naturalKeyRef -»
        «IF naturalKeyRef == null -»
                «LET this.getAllNaturalKeyAttributes() AS naturalKeys-»
                        «IF naturalKeys.size == 1 -»
                        ""+
                        «ENDIF-»
                        «FOREACH naturalKeys AS key SEPARATOR ' + " | " + '-»
                        «prefix».get«key.name.toFirstUpper()»()
                        «ENDFOREACH-»
                «ENDLET-»
        «ELSE -»
                «IF naturalKeyRef.to.getAllNaturalKeyAttributes().size == 1 -»
                ""+
                «ENDIF-»
                «FOREACH naturalKeyRef.to.getAllNaturalKeyAttributes() AS a 
SEPARATOR ' +
" | " + '-»
        
«prefix».get«naturalKeyRef.name.toFirstUpper()»().get«a.name.toFirstUpper()»()
                «ENDFOREACH-»
        «ENDIF-»
        «ENDLET-»
«ELSEIF getConstructorParameters().select(p | p.metaType == Attribute).size
> 0 -»
        «LET this.getConstructorParameters().select(p | p.metaType == 
Attribute) AS
params-»
                «IF params.size == 1 -»
                ""+
                «ENDIF-»
                «FOREACH params AS param SEPARATOR ' + " | " + '-»
                «prefix».get«param.name.toFirstUpper()»()
                «ENDFOREACH-»
        «ENDLET-»
«ELSE-»
        «LET this.getAllNonSystemAttributes() AS atts-»
                «IF atts.size == 1 -»
                ""+
                «ENDIF-»
                «FOREACH atts AS att SEPARATOR ' + " | " + '-»
                «prefix».get«att.name.toFirstUpper()»()
                «ENDFOREACH-»
        «ENDLET-»
«ENDIF-»
«ENDDEFINE»




 

eugeis wrote:
> 
> Hello,
> 
> the generated ActionBase, ValidatorBase  classes has compile error if
> model has primitive types (int, long, float). If I use Integer, Long,
> Float then Validator is Ok, but Actions not.
> 
> 1. Type mismatch: cannot convert from int/float/long to String
> 2. The operator == is undefined for the argument type(s) int/float/long,
> null
> 
> Example:
> 
> Model
> 
>               Entity Ausgabe {
>                 scaffold
>                 Date datum
>                 float betrag
>                 - @AusgabenZweck zweck
>                 - @Mitarbeiter mitarbeiter <-> ausgaben
>               }
> 
> 
> ......
> public class UpdateAusgabeValidatorBase implements Validator {
> 
> ...
>     public void validateAusgabe(UpdateAusgabeForm form, Errors errors) {
>         if (form.getDatum() == null) {
>             errors.rejectValue("datum", "required");
>         }
> 
>         if (form.getBetrag() == null) {  // form.getBetrag() is a float
> value!
>             errors.rejectValue("betrag", "required");
>         }
>     }
> }
> ....
> 
> 
>         ValueObject Note {
>               Date datum
>               float note
>           - @Fach fach
>         }
> 
> 
>         Entity Fach {
>         scaffold
>           float gebuehr
>           - @Bezeichnung bezeichnung
>           - @Schuljahr schuljahr <-> faecher
>           - @Mitarbeiter lehrer
>           - List<@Termin> termine
>           - List<@Gruppe> gruppen <-> faecher
>         }
> 
> 
> 
> 
> 
> public class CreateNoteActionBase extends FormAction {
> ....
> 
>     protected List getFachItems() {
>         Collection fach = fachService.findAll(ServiceContextStore.get());
>         List items = new ArrayList();
>         for (Fach fachItem : fach) {
>             if (fachItem instanceof Fach) {
>                 String label = fachItem.getGebuehr(); // 
> fachItem.getGebuehr() is float
> 
>                 items.add(new SelectItem(fachItem.getId(), label));
>             }
>         }
>         return items;
>     }
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JSF%3A-Generated-ActionBase-and-ValidatorBase-classes---compile--Error-%28Type-mismatch%2C-%3D%3D-is-undefined%29-tp19685911s17564p19815650.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fornax-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to