You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Hugo Ferreira <hf...@gmail.com> on 2020/08/13 08:52:46 UTC

Warning in a binding for a Interface

If I do: FormItem label="{LocaleManager.localeStrings.LoginEMail}"

I get: Warning: Data binding will not be able to detect assignments to
'LoginEMail'
localeStrings returns of type Interface and at runtime it returns an object
to implements the interface (I have [Binding] on the interface, the class
that implements the interface and also in the LocaleManager).

BUT:

If I change the LoginEMail getter on the interface to a function: FormItem
label="{LocaleManager.localeStrings.LoginEMail()}"

The warning goes away.

I would like to go through the getter approach instead of the method but
this warning is pushing me away.

Is I doing something wrong or this is a bug on the compiler (if so, can I
silence this type of warning) ?

Re: Warning in a binding for a Interface

Posted by Hugo Ferreira <hf...@gmail.com>.
More info:

This is my Interface:
package pt.solidsoft.gc.language
{
[Bindable]
public interface ILanguage
{
function get LoginCompany():String
function get LoginEMail():String
function get LoginPassword():String
}
}

This is my LocaleManager:
package pt.solidsoft.gc.language
{
public class LocaleManager
{
public static const LANGUAGE_PORTUGUESE:String = "LanguagePortuguese";
public static const LANGUAGE_SPANISH:String = "LanguageSpanish";
public static const LANGUAGE_ENGLISH:String = "LanguageEnglish";

private static var languagePortuguese:ILanguage = new Portuguese();
private static var languageSpanish:ILanguage = new Spanish();
private static var languageEnglish:ILanguage = new English();

private static var selectedLanguage:String = LANGUAGE_PORTUGUESE;

public static function setLanguage(language:String):void
{
selectedLanguage = language;
}

[Bindable]
public static function get localeStrings():ILanguage
{
switch (selectedLanguage)
{
case LANGUAGE_PORTUGUESE:
return languagePortuguese;
break;
case LANGUAGE_SPANISH:
return languageSpanish;
break;
default:
return languageEnglish;
break;
}
}
}
}

And finally the use of the localization:
...
<c:FormItem label="{LocaleManager.localeStrings.LoginCompany}"
stackedLayout="true">
<c:TextInput width="250"/>
</c:FormItem>
...

I get a compile warning (DataBinding) on LoginCompany however the
DataBinding works.

If I change
from: function get LoginCompany():String
to: function LoginCompany():String
and the caller
from: {LocaleManager.localeStrings.LoginCompany()}
to: {LocaleManager.localeStrings.LoginCompany}
It works the same but the compile warning is gone.

I would prefer the getter method but without the warning.

Hugo Ferreira <hf...@gmail.com> escreveu no dia quinta, 13/08/2020
à(s) 09:52:

> If I do: FormItem label="{LocaleManager.localeStrings.LoginEMail}"
>
> I get: Warning: Data binding will not be able to detect assignments to
> 'LoginEMail'
> localeStrings returns of type Interface and at runtime it returns an
> object to implements the interface (I have [Binding] on the interface, the
> class that implements the interface and also in the LocaleManager).
>
> BUT:
>
> If I change the LoginEMail getter on the interface to a function: FormItem
> label="{LocaleManager.localeStrings.LoginEMail()}"
>
> The warning goes away.
>
> I would like to go through the getter approach instead of the method but
> this warning is pushing me away.
>
> Is I doing something wrong or this is a bug on the compiler (if so, can I
> silence this type of warning) ?
>
>

Re: Warning in a binding for a Interface

Posted by Hugo Ferreira <hf...@gmail.com>.
More info:

This is my Interface:
package pt.solidsoft.gc.language
{
[Bindable]
public interface ILanguage
{
function get LoginCompany():String
function get LoginEMail():String
function get LoginPassword():String
}
}

This is my LocaleManager:
package pt.solidsoft.gc.language
{
public class LocaleManager
{
public static const LANGUAGE_PORTUGUESE:String = "LanguagePortuguese";
public static const LANGUAGE_SPANISH:String = "LanguageSpanish";
public static const LANGUAGE_ENGLISH:String = "LanguageEnglish";

private static var languagePortuguese:ILanguage = new Portuguese();
private static var languageSpanish:ILanguage = new Spanish();
private static var languageEnglish:ILanguage = new English();

private static var selectedLanguage:String = LANGUAGE_PORTUGUESE;

public static function setLanguage(language:String):void
{
selectedLanguage = language;
}

[Bindable]
public static function get localeStrings():ILanguage
{
switch (selectedLanguage)
{
case LANGUAGE_PORTUGUESE:
return languagePortuguese;
break;
case LANGUAGE_SPANISH:
return languageSpanish;
break;
default:
return languageEnglish;
break;
}
}
}
}

And finally the use of the localization:
...
<c:FormItem label="{LocaleManager.localeStrings.LoginCompany}"
stackedLayout="true">
<c:TextInput width="250"/>
</c:FormItem>
...

I get a compile warning (DataBinding) on LoginCompany however the
DataBinding works.

If I change
from: function get LoginCompany():String
to: function LoginCompany():String
and the caller
from: {LocaleManager.localeStrings.LoginCompany()}
to: {LocaleManager.localeStrings.LoginCompany}
It works the same but the compile warning is gone.

I would prefer the getter method but without the warning.

Hugo Ferreira <hf...@gmail.com> escreveu no dia quinta, 13/08/2020
à(s) 09:52:

> If I do: FormItem label="{LocaleManager.localeStrings.LoginEMail}"
>
> I get: Warning: Data binding will not be able to detect assignments to
> 'LoginEMail'
> localeStrings returns of type Interface and at runtime it returns an
> object to implements the interface (I have [Binding] on the interface, the
> class that implements the interface and also in the LocaleManager).
>
> BUT:
>
> If I change the LoginEMail getter on the interface to a function: FormItem
> label="{LocaleManager.localeStrings.LoginEMail()}"
>
> The warning goes away.
>
> I would like to go through the getter approach instead of the method but
> this warning is pushing me away.
>
> Is I doing something wrong or this is a bug on the compiler (if so, can I
> silence this type of warning) ?
>
>

Re: Warning in a binding for a Interface

Posted by hferreira <hf...@gmail.com>.
More info:

This is my Interface:
package pt.solidsoft.gc.language
{
    [Bindable]
    public interface ILanguage
    {
        function get LoginCompany():String
        function get LoginEMail():String
        function get LoginPassword():String
    }
}

This is my LocaleManager:
package pt.solidsoft.gc.language
{
    public class LocaleManager
    {
        public static const LANGUAGE_PORTUGUESE:String =
"LanguagePortuguese";
        public static const LANGUAGE_SPANISH:String = "LanguageSpanish";
        public static const LANGUAGE_ENGLISH:String = "LanguageEnglish";

        private static var languagePortuguese:ILanguage = new Portuguese();
        private static var languageSpanish:ILanguage = new Spanish();
        private static var languageEnglish:ILanguage = new English();

        private static var selectedLanguage:String = LANGUAGE_PORTUGUESE;

        public static function setLanguage(language:String):void
        {
            selectedLanguage = language;
        }

        [Bindable]
        public static function get localeStrings():ILanguage
        {
            switch (selectedLanguage)
            {
                case LANGUAGE_PORTUGUESE:
                    return languagePortuguese;
                    break;
                case LANGUAGE_SPANISH:
                    return languageSpanish;
                    break;
                default:
                    return languageEnglish;
                    break;
            }
        }
    }
}

And finally the use of the localization:
...
                <c:FormItem
label="{LocaleManager.localeStrings.LoginCompany}"
                            stackedLayout="true">
                    <c:TextInput width="250"/>
                </c:FormItem>
...

I get a compile warning (DataBinding) on LoginCompany however the
DataBinding works.

If I change
from: function get LoginCompany():String 
to:   function LoginCompany():String
and the caller
from: {LocaleManager.localeStrings.LoginCompany()}
to:   {LocaleManager.localeStrings.LoginCompany}
It works the same but the compile warning is gone.

I would prefer the getter method but without the warning.



--
Sent from: http://apache-royale-development.20373.n8.nabble.com/

Re: Warning in a binding for a Interface

Posted by Hugo Ferreira <hf...@gmail.com>.
I missed to ; at the end of the line in the interface.
Combined with [Bindable] in each property, the warning goes away.

All this versions compile and works but with bindable warnings:
[Bindable]
public interface ILanguage
{
function get LoginCompany():String
function get LoginEMail():String
function get LoginPassword():String
}

public interface ILanguage
{
[Bindable] function get LoginCompany():String
[Bindable] function get LoginEMail():String
[Bindable] function get LoginPassword():String
}

[Bindable]
public interface ILanguage
{
function get LoginCompany():String;
function get LoginEMail():String;
function get LoginPassword():String;
}

Only this version compile, works and without bindable warnings:
public interface ILanguage
{
[Bindable] function get LoginCompany():String;
[Bindable] function get LoginEMail():String;
[Bindable] function get LoginPassword():String;
}

Solved for now.

Hugo Ferreira <hf...@gmail.com> escreveu no dia quinta, 13/08/2020
à(s) 09:52:

> If I do: FormItem label="{LocaleManager.localeStrings.LoginEMail}"
>
> I get: Warning: Data binding will not be able to detect assignments to
> 'LoginEMail'
> localeStrings returns of type Interface and at runtime it returns an
> object to implements the interface (I have [Binding] on the interface, the
> class that implements the interface and also in the LocaleManager).
>
> BUT:
>
> If I change the LoginEMail getter on the interface to a function: FormItem
> label="{LocaleManager.localeStrings.LoginEMail()}"
>
> The warning goes away.
>
> I would like to go through the getter approach instead of the method but
> this warning is pushing me away.
>
> Is I doing something wrong or this is a bug on the compiler (if so, can I
> silence this type of warning) ?
>
>