You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2017/04/17 04:51:30 UTC

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Hi Justin,

What is the scenario where everybody will need this code?

-Alex

On 4/16/17, 9:24 PM, "jmclean@apache.org" <jm...@apache.org> wrote:

>replace existing format bead if it exists
>
>
>Project: 
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Frepo&data=02%7C01%7C%7C3ef9e6a946c
>4448e037308d48549af37%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6362799
>98897039088&sdata=qaow7yDdU0PKcYss05ng7b7q4SXBnlyvp6b%2BOjCPGgU%3D&reserve
>d=0
>Commit: 
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fcommit%2F4842fa7a&data=02%7C01%7C%
>7C3ef9e6a946c4448e037308d48549af37%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%
>7C0%7C636279998897039088&sdata=gp5gH75saXS6x6mq8Q5L4ut3aQHCABcc%2BvN5s59fp
>2k%3D&reserved=0
>Tree: 
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Ftree%2F4842fa7a&data=02%7C01%7C%7C
>3ef9e6a946c4448e037308d48549af37%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C
>0%7C636279998897039088&sdata=20%2FVuKlRYdoA1ZIobKbCUMggT1zvnkMnn5FBWWktjeI
>%3D&reserved=0
>Diff: 
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fdiff%2F4842fa7a&data=02%7C01%7C%7C
>3ef9e6a946c4448e037308d48549af37%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C
>0%7C636279998897039088&sdata=lfk9qgcbF3yI9ncMjkIykEmloaHMnNB8tytiirKpxAU%3
>D&reserved=0
>
>Branch: refs/heads/develop
>Commit: 4842fa7a15a756026dcfa1ca4262039fded2db59
>Parents: 23f3c5a
>Author: Justin Mclean <jm...@apache.org>
>Authored: Mon Apr 17 14:22:32 2017 +1000
>Committer: Justin Mclean <jm...@apache.org>
>Committed: Mon Apr 17 14:22:32 2017 +1000
>
>----------------------------------------------------------------------
> .../main/flex/org/apache/flex/html/DateField.as | 22 ++++++++++++++++++++
> .../main/flex/org/apache/flex/html/DateField.as | 22 ++++++++++++++++++++
> 2 files changed, 44 insertions(+)
>----------------------------------------------------------------------
>
>
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F4842fa7a%2Fframeworks%2Fpro
>jects%2FBasic%2Fsrc%2Fmain%2Fflex%2Forg%2Fapache%2Fflex%2Fhtml%2FDateField
>.as&data=02%7C01%7C%7C3ef9e6a946c4448e037308d48549af37%7Cfa7b1b5a7b3443879
>4aed2c178decee1%7C0%7C0%7C636279998897039088&sdata=lZFZ8SMVm6ygKxckfrk%2Bs
>Atp1d%2F9vNMXYi7eXUbYgqw%3D&reserved=0
>----------------------------------------------------------------------
>diff --git 
>a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.a
>s 
>b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.a
>s
>index f46e453..ca142ba 100644
>--- 
>a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.a
>s
>+++ 
>b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/DateField.a
>s
>@@ -20,6 +20,7 @@ package org.apache.flex.html
> {
> 	import org.apache.flex.core.IBead;
> 	import org.apache.flex.core.IDateChooserModel;
>+	import org.apache.flex.core.IFormatBead;
> 	import org.apache.flex.core.UIBase;
> 	import org.apache.flex.core.ValuesManager;
> 	
>@@ -74,6 +75,27 @@ package org.apache.flex.html
>             
> 			super.addedToParent();
> 		}
>+
>+		/**
>+		 *  Replace existing format bead if it exists.
>+		 *
>+		 *  @copy org.apache.flex.core.IStrand#addBead()
>+		 *
>+		 *  @langversion 3.0
>+		 *  @playerversion Flash 10.2
>+		 *  @playerversion AIR 2.6
>+		 *  @productversion FlexJS 0.0
>+		 */
>+		override public function addBead(bead:IBead):void
>+		{
>+			if (bead is IFormatBead) {
>+				var formatBead:IBead = getBeadByType(IFormatBead);
>+				if (formatBead != null) {
>+					removeBead(formatBead);
>+				}
>+			}
>+			super.addBead(bead);
>+		}
> 		
> 		/**
> 		 *  The currently selected date (or null if no date has been selected).
>
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit-wip-us
>.apache.org%2Frepos%2Fasf%2Fflex-asjs%2Fblob%2F4842fa7a%2Fframeworks%2Fpro
>jects%2FHTML%2Fsrc%2Fmain%2Fflex%2Forg%2Fapache%2Fflex%2Fhtml%2FDateField.
>as&data=02%7C01%7C%7C3ef9e6a946c4448e037308d48549af37%7Cfa7b1b5a7b34438794
>aed2c178decee1%7C0%7C0%7C636279998897039088&sdata=5Lo6umoXpjQFdmhsQ8WtnByf
>YJhYKGT05zk28c69xe0%3D&reserved=0
>----------------------------------------------------------------------
>diff --git 
>a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateField.as
> 
>b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateField.as
>index f33db9d..5b73db0 100644
>--- 
>a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateField.as
>+++ 
>b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateField.as
>@@ -20,6 +20,7 @@ package org.apache.flex.html
> {
> 	import org.apache.flex.core.IBead;
> 	import org.apache.flex.core.IDateChooserModel;
>+	import org.apache.flex.core.IFormatBead;
> 	import org.apache.flex.core.UIBase;
> 	import org.apache.flex.core.ValuesManager;
> 	
>@@ -75,6 +76,27 @@ package org.apache.flex.html
>             
> 			super.addedToParent();
> 		}
>+
>+		/**
>+		 *  Replace existing format bead if it exists.
>+		 *
>+		 *  @copy org.apache.flex.core.IStrand#addBead()
>+		 *
>+		 *  @langversion 3.0
>+		 *  @playerversion Flash 10.2
>+		 *  @playerversion AIR 2.6
>+		 *  @productversion FlexJS 0.0
>+		 */
>+		override public function addBead(bead:IBead):void
>+		{
>+			if (bead is IFormatBead) {
>+				var formatBead:IBead = getBeadByType(IFormatBead);
>+				if (formatBead != null) {
>+					removeBead(formatBead);
>+				}
>+			}
>+			super.addBead(bead);
>+		}
> 		
> 		/**
> 		 *  The currently selected date (or null if no date has been selected).
>


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

Also SWF is not an option in this environment. Otherwise the project would most likely be using the regular SDK and not FlexJS.

But as yo say Intl support may be useful for someone else so could be useful to be implemented, it's just probably not going to be very useful on this project.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> So how do you plan to detect which date format to use?

In most case to avoid any potential confusion will use month names.

> Whatever you do could be encapsulated into a bead and shared with others.

Sure that’s my plan. I’ve already checked in a couple that are likely to be useful.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.

On 4/18/17, 10:04 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>> Well, who is in the 20% that will see dates in the wrong format?  Are
>>the
>> likely customers of FlexJS this year?
>
>Yes. It very likely effects current users of a FlexJS application I’m
>working on / has been deployed.
>
>I would need to get access to browser stats to be 100% sure. But given
>some users are in a corporate environment that uses older versions of
>outlook I’d expect some IE 10 or lower use.

So how do you plan to detect which date format to use?  Whatever you do
could be encapsulated into a bead and shared with others.

-Alex


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> Well, who is in the 20% that will see dates in the wrong format?  Are the
> likely customers of FlexJS this year?

Yes. It very likely effects current users of a FlexJS application I’m working on / has been deployed.

I would need to get access to browser stats to be 100% sure. But given some users are in a corporate environment that uses older versions of outlook I’d expect some IE 10 or lower use.

Thanks,
Justin


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.

On 4/18/17, 3:50 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>> Because the user has choices (this is not required code that everybody
>> must use) 80% is good enough for me.
>
>Again than mean that 20% of people using the application would see dates
>in the wrong format. Depending on the application they would get
>birthdays wrong or show up to meetings on the wrong day (and month).

Well, who is in the 20% that will see dates in the wrong format?  Are the
likely customers of FlexJS this year?  Next year?  Won't the 20% be much
closer to zero in two years?  Could those who need to serve that 20% use
the SWF version?

Also, is there some other code we could add that makes the 20% much less?
Like looking at navigator.language and then guessing based on that?
That's the advantage of beads.  We can offer different kinds of
implementations for different needs.

>
>Each to their own but I don’t think that's a feature I would use as it
>would cause numerous user complaints and confusion.
>
>i thought we were aiming for all browsers that supported es5 as the
>minimum browser spec? I guess optional beads may decide to support a
>narrower set of browsers but if they do IMO they should come with very
>big warnings.

We are trying to keep IE9 as the lowest version, but different beads can
have different requirements.  There is an HTML5 SWC that requires HTML5
browser support.  Not a big deal to create something that relies on IE11.
And that's why I am still pushing for SWF equivalence.  It makes it
possible to deploy the app on IE<9 if you need to since most old browsers
support Flash.

It's ok if you don't want to do it.  Some other volunteer can.

-Alex


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> Because the user has choices (this is not required code that everybody
> must use) 80% is good enough for me. 

Again than mean that 20% of people using the application would see dates in the wrong format. Depending on the application they would get birthdays wrong or show up to meetings on the wrong day (and month).

Each to their own but I don’t think that's a feature I would use as it would cause numerous user complaints and confusion.

i thought we were aiming for all browsers that supported es5 as the minimum browser spec? I guess optional beads may decide to support a narrower set of browsers but if they do IMO they should come with very big warnings.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.

On 4/17/17, 11:34 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>>It looks like the Intl class is pretty well supported on JS these days?
>
>Sadly not, it’s supported but not everywhere [1] - about 80% globally. So
>more people can’t use Intl than need the US date format. :-)

Because the user has choices (this is not required code that everybody
must use) 80% is good enough for me.  I assume that number is climbing
every day.

We could also write another bead that tries to use other techniques like
navigator.language to determine the format.  This is another good case for
beads.  Different folks will use different beads based on their needs.  If
I'm just doing a mobile app for Android/IOS, I can use the Intl bead.

Any volunteers to work on these beads?

-Alex


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

Missing [1]  reference in my last email was http://caniuse.com/#search=Intl

Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
HI,

> The recommended pattern is in UIBase and hopefully elsewhere.

I’ll give that a try.

> Do we need resources in order to make a locale-dependant DateFormat bead?

Probably not but I’ve no idea can you can conditionally include classes in CSS based on locale or pass property of a bead based on locale in CSS.

> IMO, with PAYG, you could bake in a specific format that doesn't have to
> query the current locale or choose one that does.

Which is what we currently have.

> It looks like the Intl class is pretty well supported on JS these days?

Sadly not, it’s supported but not everywhere [1] - about 80% globally. So more people can’t use Intl than need the US date format. :-)

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.

On 4/18/17, 3:44 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>> What does your attempt to use the pattern look like?
>
>if (getBeadByType(IFormatBead) == null) {
>	var klass:* = ValuesManager.valuesImpl.getValue(this, "iFormatBead");
>	var bead:IBead = new klass() as IBead;
>	if (bead) {
>		addBead(bead);
>	}
>}
>
>>  Did you apply the pattern inside addedToParent()?
>
>Yes
>
>>  Did you apply the pattern after super.addedToParent()?
>
>Before as that’s what the existing code did, but from what Peter written
>it seems that super call needs to be after.

Typically, the super.addParent() call goes first in order to apply any
beads specified in MXML.

HTH,
-Alex


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> What does your attempt to use the pattern look like?

if (getBeadByType(IFormatBead) == null) {
	var klass:* = ValuesManager.valuesImpl.getValue(this, "iFormatBead");
	var bead:IBead = new klass() as IBead;
	if (bead) {
		addBead(bead);
	}
}

>  Did you apply the pattern inside addedToParent()?

Yes

>  Did you apply the pattern after super.addedToParent()?

Before as that’s what the existing code did, but from what Peter written it seems that super call needs to be after.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.
What does your attempt to use the pattern look like?  Did you apply the
pattern inside addedToParent()?  If so, what is the full code of
addedToParent()?  Did you apply the pattern after super.addedToParent()?

-Alex

On 4/18/17, 1:41 AM, "justin@classsoftware.com" <ju...@classsoftware.com>
wrote:

>Hi,
>
>> It looks to related to a bug in getBeadByType.
>
>And the reason for that is the addBead call to add DateFormatDDMMYYYYBead
>is called after DateField addedToParent is called Or if you prefer at the
>time addedToParent is called the beads have not been added so it will add
>the one defined in the CSS. Only the first iFormat bead will have an
>effect.
>
>Thanks,
>Justin


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Peter Ent <pe...@adobe.com>.
It is supposed to work like this:

A: You may have zero or more beads defined inline in MXML for your
component using <js:beads> property.

B: You may have zero or more beads defined in CSS for your component.

When addElement is called on your component, it will add the underlying
element to the display list and then call addedToParent() on the component
and process the inline beads first (situation A).

Once the inline beads are added (and their strand setters are called), the
"standard" set of beads may be added: model, view, and controller. This
done by first seeing if one is already on the beads list (e.g. added
inline). If it is not present, then the CSS (situation B) is examined
using ValuesManager. If a bead class is found, it is instantiated and then
added to the strand's beads list (the bead's strand setter is called).

When the "standard" beads have been added, addedToParent() finished by
dispatching "beadsAdded" on the strand.

C: Any beads in CSS that are non-standard are not automatically added.

If your component class overrides addedToParent() it should call
super.addedToParent() right away to load the inline and standard beads.

After calling super.addedToParent(), your component can then load custom
beads (e.g., a date formatter) by following the same pattern
addedToParent() follows: Using an interface type, does the bead already
exist on the strand (added inline)? If not, is there a class for it in CSS
via ValuesManager? If so, create a new instance and add it to the bead
list.

The reason for this sequence is to allow inline beads to override default
beads (default beads being added in addedToParent()). So if your component
loads the ABCBead in its addedToParent() override, I can use your
component and put in my custom DEFBead which either extends ABCBead or
implements IMyCustomBead interface (which ABCBead should also implement).
This bead will be loaded early (in super.addedToParent()) and will not get
replaced by the default later.

Since "beadsAdded" was already dispatched, your component might want to
either dispatch "initComplete" or some custom event. Note that the
container classes (GroupBase/Group, ContainerBase/Container, etc.) all
dispatch "initComplete" so if your basing your component on a container
type, you don't have to dispatch "initComplete" but you can dispatch a
custom event.

I hope that helps.
‹peter

On 4/18/17, 4:41 AM, "justin@classsoftware.com" <ju...@classsoftware.com>
wrote:

>Hi,
>
>> It looks to related to a bug in getBeadByType.
>
>And the reason for that is the addBead call to add DateFormatDDMMYYYYBead
>is called after DateField addedToParent is called Or if you prefer at the
>time addedToParent is called the beads have not been added so it will add
>the one defined in the CSS. Only the first iFormat bead will have an
>effect.
>
>Thanks,
>Justin


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by ju...@classsoftware.com.
Hi,

> It looks to related to a bug in getBeadByType.

And the reason for that is the addBead call to add DateFormatDDMMYYYYBead is called after DateField addedToParent is called Or if you prefer at the time addedToParent is called the beads have not been added so it will add the one defined in the CSS. Only the first iFormat bead will have an effect.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by ju...@classsoftware.com.
Hi,

> JFYI - Tried it and it fails to fix the issue.

It looks to related to a bug in getBeadByType. It’s checking _beads not beads and at this point beads has a single element in it but _beads is empty so this line:

if (!_beads) return null;

returns null and it doesn’t run the rest of the method and goes ahead and adds the bead defined in the CSS.

Some sample code that reporduces this issue:

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:js="library://ns.apache.org/flexjs/basic"
                xmlns:accessories="org.apache.flex.html.accessories.*">

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl/>
    </js:valuesImpl>

    <js:initialView>
        <js:View>
            <js:Group>
                <js:beads>
                    <js:VerticalLayout />
                </js:beads>
                <js:Label text="Default" />
                <js:DateField>
                    <js:beads>
                        <accessories:DateFormatDDMMYYYYBead />
                    </js:beads>
                </js:DateField>
            </js:Group>
        </js:View>
    </js:initialView>

</js:Application>

Thanks,
Justin



Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> There are variants where you do something like:
> 
>  var controller:IBeadController = getBeadByType(IBeadController);
>  If (controller == null)
>  {
>    c = ValuesManager.valuesImpl.getValue(this, "iBeadController") as
> Class;
>    if (c)
>    {
>       controller = new c as IBeadController;
>       if (controller)
>         addBead(controller);
>    }
>  }

JFYI - Tried it and it fails to fix the issue.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.

On 4/17/17, 9:48 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>> That would imply a bug elsewhere DateField.
>
>DateField consist of 3 functions addedToParent and a selectedDate
>setter/getter. How would you fix this bug?
>
>>  The pattern all components
>> should be using is to define an interface for a class of beads, maybe
>> something like IDateFormatBead.
>
>It does exactly this it uses IFormatBead. See the (unmodified) code in
>addedToParent in particular this line:
>var klass:* = ValuesManager.valuesImpl.getValue(this,"iFormatBead");
>
>> Then the code, usually in addedToParent()
>> should use getBeadByType() to see if there is an IDateFormatBead and
>>only
>> if there isn't should it go see if there is a default in CSS.
>
>So addedToParent should call getBeadByType rather than getValue? The
>method was original written by you I believe.

The recommended pattern is in UIBase and hopefully elsewhere:

  if (getBeadByType(IBeadController) == null)
  {
    c = ValuesManager.valuesImpl.getValue(this, "iBeadController") as
Class;
    if (c)
    {
      var controller:IBeadController = new c as IBeadController;
      if (controller)
        addBead(controller);
    }
  }

There are variants where you do something like:

  var controller:IBeadController = getBeadByType(IBeadController);
  If (controller == null)
  {
    c = ValuesManager.valuesImpl.getValue(this, "iBeadController") as
Class;
    if (c)
    {
       controller = new c as IBeadController;
       if (controller)
         addBead(controller);
    }
  }




>
>> I noticed that there was a commit that changed the default date format
>> away from US format.
>
>For dates like 04-12-2017 most of the world would read that as 4th of
>December not the 12th of April. See
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wikipe
>dia.org%2Fwiki%2FDate_format_by_country&data=02%7C01%7C%7Cb00df717e4ad4d4e
>d42608d48616350a%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636280877325
>813359&sdata=4oxuGnBG08JW%2BHE03kWBVfgsGFg2hu3eIEFj63j4MjI%3D&reserved=0
>
>> How did we manage the default format in regular Flex?
>
>It was locale dependant (specified in the shared resources resource
>file), currently FlexJS doesn’t support resource files.

Do we need resources in order to make a locale-dependant DateFormat bead?
IMO, with PAYG, you could bake in a specific format that doesn't have to
query the current locale or choose one that does.  It looks like the Intl
class is pretty well supported on JS these days?  Would that and
flash.globalization "do the right thing" without a whole resource
subsystem?

-Alex


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> That would imply a bug elsewhere DateField.

DateField consist of 3 functions addedToParent and a selectedDate setter/getter. How would you fix this bug?

>  The pattern all components
> should be using is to define an interface for a class of beads, maybe
> something like IDateFormatBead.

It does exactly this it uses IFormatBead. See the (unmodified) code in addedToParent in particular this line:
var klass:* = ValuesManager.valuesImpl.getValue(this,"iFormatBead");

> Then the code, usually in addedToParent()
> should use getBeadByType() to see if there is an IDateFormatBead and only
> if there isn't should it go see if there is a default in CSS.

So addedToParent should call getBeadByType rather than getValue? The method was original written by you I believe.

> I noticed that there was a commit that changed the default date format
> away from US format.

For dates like 04-12-2017 most of the world would read that as 4th of December not the 12th of April. See https://en.wikipedia.org/wiki/Date_format_by_country

> How did we manage the default format in regular Flex?

It was locale dependant (specified in the shared resources resource file), currently FlexJS doesn’t support resource files.

Thanks,
Justin

Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Alex Harui <ah...@adobe.com>.

On 4/17/17, 8:31 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>HI,
>
>> What is the scenario where everybody will need this code?
>
>If they want to use a date formatter and not have dates displayed as
>“YYYY-MM-DD”.
>
>Before these changes dates would be formatted as US style dates by
>default and if you added a different date format bead it would still
>incorrectly display in US date format. Middle endian / US style dates
>should not be the default as they are only used by about 5-10% of the
>world’s population. If you prefer I can change the default to
>"DD/MM/YYYY” rather than YYYY-MM-DD format  (ISO 8601).
>
>Basically code like this would still display US style dates.
><js:DateField>
>    <js:beads>
>        <accessories:DateFormatDDMMYYYYBead />
>    </js:beads>
></js:DateField>
>
>Reason being that it was just finding the first IFormatBead which was
>defined in the CSS, any other IFormatBead bead the user added would be
>ignored.

That would imply a bug elsewhere DateField.  The pattern all components
should be using is to define an interface for a class of beads, maybe
something like IDateFormatBead. Then the code, usually in addedToParent()
should use getBeadByType() to see if there is an IDateFormatBead and only
if there isn't should it go see if there is a default in CSS.

I noticed that there was a commit that changed the default date format
away from US format.  How did we manage the default format in regular Flex?

-Alex


Re: [4/6] git commit: [flex-asjs] [refs/heads/develop] - replace existing format bead if it exists

Posted by Justin Mclean <ju...@classsoftware.com>.
HI,

> What is the scenario where everybody will need this code?

If they want to use a date formatter and not have dates displayed as “YYYY-MM-DD”.

Before these changes dates would be formatted as US style dates by default and if you added a different date format bead it would still incorrectly display in US date format. Middle endian / US style dates should not be the default as they are only used by about 5-10% of the world’s population. If you prefer I can change the default to "DD/MM/YYYY” rather than YYYY-MM-DD format  (ISO 8601).

Basically code like this would still display US style dates.
<js:DateField>
    <js:beads>
        <accessories:DateFormatDDMMYYYYBead />
    </js:beads>
</js:DateField>

Reason being that it was just finding the first IFormatBead which was defined in the CSS, any other IFormatBead bead the user added would be ignored.

Thanks,
Justin