On Thu, Nov 7, 2013 at 2:18 PM, Alex Harui <[email protected]> wrote: > FWIW, I was thinking that this kind of check should be replaced by some > capability in the tool chain to verify a configuration, maybe by marking > some values as required. In production, you hopefully don't need these > kinds of checks. I've also floated the idea of "debug-mode" beads which > have more checks than production beads. > > Thoughts? >
Personally, I don't like the idea of setting the bead values in CSS. It makes it hard to enforce these kind of things. Ideally, the absence of a bead that the code is looking for should generate a compile error. Another way to inject beads would be to use metadata attributes. Something along the lines of spark skins' [SkinPart(required="true")] metadata attribute. Would this make it easier to do the checks? Or more simpler, maybe we have default empty IBeads available so that things at least don't blow up. But I am guessing that this approach might only delay the blow up of the code to a later stage. Thanks, Om > -Alex > > On 11/7/13 11:36 AM, "[email protected]" <[email protected]> > wrote: > > >If bead value is not found, prevent set states from blowing up. > > > > > >Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo > >Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/425d9613 > >Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/425d9613 > >Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/425d9613 > > > >Branch: refs/heads/develop > >Commit: 425d9613964db13b09d6d80ee1a8d332cf0dcb2c > >Parents: 74c50e4 > >Author: Om <[email protected]> > >Authored: Thu Nov 7 11:16:59 2013 -0800 > >Committer: Om <[email protected]> > >Committed: Thu Nov 7 11:34:41 2013 -0800 > > > >---------------------------------------------------------------------- > > frameworks/as/src/org/apache/flex/core/ViewBase.as | 11 +++++++++-- > > 1 file changed, 9 insertions(+), 2 deletions(-) > >---------------------------------------------------------------------- > > > > > > > http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/425d9613/frameworks/ > >as/src/org/apache/flex/core/ViewBase.as > >---------------------------------------------------------------------- > >diff --git a/frameworks/as/src/org/apache/flex/core/ViewBase.as > >b/frameworks/as/src/org/apache/flex/core/ViewBase.as > >index 4e923a1..afeb04d 100644 > >--- a/frameworks/as/src/org/apache/flex/core/ViewBase.as > >+++ b/frameworks/as/src/org/apache/flex/core/ViewBase.as > >@@ -81,8 +81,15 @@ package org.apache.flex.core > > public function set states(value:Array):void > > { > > _states = value; > >- if (getBeadByType(IStatesImpl) == null) > >- addBead(new (ValuesManager.valuesImpl.getValue(this, > >"iStatesImpl")) as IBead); > >+ try{ > >+ if (getBeadByType(IStatesImpl) == null) > >+ addBead(new > (ValuesManager.valuesImpl.getValue(this, > >"iStatesImpl")) as IBead); > >+ } > >+ //TODO: Need to handle this case more gracefully > >+ catch(e:Error) > >+ { > >+ trace(e.message); > >+ } > > > > } > > > > > >
