You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2020/03/11 19:30:02 UTC
[GitHub] [royale-asjs] nihavend opened a new issue #755: Binding function is
called after the static function in component
nihavend opened a new issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755
ImageContainer.resolveStatus(data) is called before the data is bind.
Break points :

First pause for breakpoint :

Call stack :

Second pause for breakpoint :

Call Stack :

Image is not displayed :


Here are three sources :
FindBug.xml
<?xml version="1.0" encoding="latin5" ?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.apache.org/royale/spark"
xmlns:mx="library://ns.apache.org/royale/mx"
height="600" width="800"
currentState="anaSayfaState"
xmlns:jobdetail="main.mtest.*"
creationComplete="group1_creationCompleteHandler(event)">
<fx:Metadata>
[ResourceBundle("messages")]
</fx:Metadata>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
public var jobListXml:XML =
<jobList netTreeEnablable="false" netTreeDisablable="false" >
<genericJob Id="1" groupId="iot-insights">
<visualParams>
<statu>9</statu>
</visualParams>
</genericJob>
</jobList>;
import mx.events.FlexEvent;
import mx.collections.XMLListCollection;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
[Bindable]
public var jobListXmlCollection:XMLListCollection = new XMLListCollection();
protected function group1_creationCompleteHandler(event:FlexEvent):void {
jobListXmlCollection.source = jobListXml.children();
}
]]>
</fx:Script>
<mx:Panel title="AdvancedDataGrid Control Example"
paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10"
height="100%" width="100%">
<mx:AdvancedDataGrid id="pinaraJobList" width="100%" height="100%" dataProvider="{jobListXmlCollection}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="{resourceManager.getString('messages', 'stateGrid')}" width="{this.pinaraJobList.width * 0.10}">
<mx:itemRenderer>
<fx:Component>
<s:MXAdvancedDataGridItemRenderer>
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<jobdetail:StateImageItem id="stateImageItem" data="{data}"/>
</s:MXAdvancedDataGridItemRenderer>
</fx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Panel>
</s:Application>
StateImageItem.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.apache.org/royale/spark"
xmlns:mx="library://ns.apache.org/royale/mx">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
[Bindable]
public var data:Object;
]]>
</fx:Script>
<s:Image source="{ImageContainer.resolveStatus(data)}"/>
</s:VGroup>
ImageContainer.as
package main.mtest
{
import mx.collections.ArrayList;
public class ImageContainer {
private static var statuImageList:ArrayList;
// Liste için statu ikonları
private static var _clock1:String = '/images/clock1.png';
private static var _kilit:String = '/images/kilit.png';
private static var _kosu2:String = '/images/kosu2.png';
private static var _ok2:String = '/images/ok2.png';
private static var _error:String = '/images/error.png';
private static var _timeout:String = '/images/timeout.png';
private static var _skip:String = '/images/skip.png';
private static var _stop:String = '/images/stop.png';
private static var _pause:String = '/images/pause.png';
private static var _disabled:String = '/images/disabled.png';
private static var _warning:String = '/images/warning.png';
public static function getStatuImage(statuCode:Number):String {
if(statuImageList == null || statuImageList.length == 0) {
statuImageList = new ArrayList();
statuImageList.addItem(clock1)
statuImageList.addItem(kilit)
statuImageList.addItem(kosu2)
statuImageList.addItem(ok2)
statuImageList.addItem(error)
statuImageList.addItem(timeout)
statuImageList.addItem(skip)
statuImageList.addItem(stop)
statuImageList.addItem(pause)
statuImageList.addItem(disabled)
statuImageList.addItem(warning)
}
return statuImageList.getItemAt(statuCode) as String;
}
public static function resolveStatus(data:Object):String {
var statu:int = XML(data).visualParams.statu;
// Alert.show("Vparams : " + data.visualParams);
// Alert.show("statu:" + statu + " image:" + imageList.getItemAt(statu));
return statuImageList.getItemAt(statu) as String;
}
public static function get clock1():String
{
return _clock1;
}
public static function set clock1(clock1:String):void
{
_clock1 = clock1;
}
public static function get kilit():String
{
return _kilit;
}
public static function set kilit(kilit:String):void
{
_kilit = kilit;
}
public static function get kosu2():String
{
return _kosu2;
}
public static function set kosu2(kosu2:String):void
{
_kosu2 = kosu2;
}
public static function get ok2():String
{
return _ok2;
}
public static function set ok2(ok2:String):void
{
_ok2 = ok2;
}
public static function get error():String
{
return _error;
}
public static function set error(error:String):void
{
_error = error;
}
public static function get timeout():String
{
return _timeout;
}
public static function set timeout(timeout:String):void
{
_timeout = timeout;
}
public static function get skip():String
{
return _skip;
}
public static function set skip(skip:String):void
{
_skip = skip;
}
public static function get stop():String
{
return _stop;
}
public static function set stop(stop:String):void
{
_stop = stop;
}
public static function get pause():String
{
return _pause;
}
public static function set pause(pause:String):void
{
_pause = pause;
}
public static function get disabled():String
{
return _disabled;
}
public static function set disabled(disabled:String):void
{
_disabled = disabled;
}
public static function get warning():String
{
return _warning;
}
public static function set warning(warning:String):void
{
_warning = warning;
}
private static var _disableJob:String = '/images/disableJob.png';
public static function get disableJob():String
{
return _disableJob;
}
public static function set disableJob(value:String):void
{
_disableJob = value;
}
private static var _startJob:String = '/images/startJob.png';
public static function get startJob():String
{
return _startJob;
}
public static function set startJob(value:String):void
{
_startJob = value;
}
private static var _pauseJob:String = '/images/pauseJob.png';
public static function get pauseJob():String
{
return _pauseJob;
}
public static function set pauseJob(value:String):void
{
_pauseJob = value;
}
private static var _enableJob:String = '/images/enableJob.png';
public static function get enableJob():String
{
return _enableJob;
}
public static function set enableJob(value:String):void
{
_enableJob = value;
}
private static var _retryJob:String = '/images/retryJob.png';
public static function get retryJob():String
{
return _retryJob;
}
public static function set retryJob(value:String):void
{
_retryJob = value;
}
private static var _setSuccessJob:String = '/images/setSuccessJob.png';
public static function get setSuccessJob():String
{
return _setSuccessJob;
}
public static function set setSuccessJob(value:String):void
{
_setSuccessJob = value;
}
private static var _skipJob:String = '/images/skipJob.png';
public static function get skipJob():String
{
return _skipJob;
}
public static function set skipJob(value:String):void
{
_skipJob = value;
}
private static var _stopJob:String = '/images/stopJob.png';
public static function get stopJob():String
{
return _stopJob;
}
public static function set stopJob(value:String):void
{
_stopJob = value;
}
private static var _resumeJob:String = '/images/resumeJob.png';
public static function get resumeJob():String
{
return _resumeJob;
}
public static function set resumeJob(value:String):void
{
_resumeJob = value;
}
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-598018093
I will try to remember to optimize it down to two or one.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] nihavend commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
nihavend commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-597883224
Actually it is called 4 times.
1st call : data is null, return value is not available, and no exception thrown

2nd call : data is NOT null, return value is not available, and no exception thrown

3rd call : data is null, return value is not available, and no exception thrown same 1st
4th call : data is NOT null, return value is not available, and no exception thrown 2nd
The signature of the functions :
```
public static function getStatuImage(statuCode:Number):String
public static function resolveStatus(data:Object):String
```
And the source code of the ImageContainer.as is attached above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui closed issue #755: Binding function is called
after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui closed issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-598552401
I looked into the 4 calls. It looks like "correct" behavior. One of the inefficiencies in the test case is that the XMLListCollection's source is set 3 times:
1) set to null in the app's constructor to initialize jobListXmlCollection
2) set to null to "unset" the XMLListAdapter from set in the app's constructor
3) set to the actual final XMLList.
Then, given that VGroup is used as the top tag in StateImageItem, ContainerDataBinding is running which evaluates data before it is set by the binding in the wrapping MXADGIR.
And then it gets set one final time with the right value.
It could improve performance to not initialize jobListXmlCollection and create the final XMLListCollection in the creationComplete handler.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-597878674
In the email thread, I thought you said that resolveStatus gets called twice. On the second call, ItemRendererDataBinding should be making the call. Add some debugging to verify that there is a second call and what resolveStatus returns, and also make sure you changed the method signature to return String instead of Class otherwise, no source will be assigned.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] nihavend commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
nihavend commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-597876631
according to xml the static function determines the type of the image and retrieve the path.
for this sample, the status=9
and the function resolveStatus should return : 'images/disableds.png' as path
and the html should be something like this : (manually edited the html in browser to add the src attribute to show you)

but not :

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-598008829
I altered resolveStatus to :
```
public static function resolveStatus(data:Object):String {
var statu:int = XML(data).visualParams.statu;
// Alert.show("Vparams : " + data.visualParams);
// Alert.show("statu:" + statu + " image:" + imageList.getItemAt(statu));
return getStatuImage(statu) as String;
}
```
And the IMG tag properly got its URL
```
<img class="Image" src="images/disableds.png" style="position: absolute;">
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] nihavend edited a comment on issue #755: Binding
function is called after the static function in component
Posted by GitBox <gi...@apache.org>.
nihavend edited a comment on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-597876631
according to xml the static function determines the type of the image and retrieve the path.
for this sample, the status=9
and the function resolveStatus should return : 'images/disableds.png' as path
and the html should be something like this : (manually edited the html in browser to add the src attribute to show you)

the view :

but not :

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-597871813
The call stack shows that ContainerDataBinding is making the call. We can optimize that away, but it should not be affecting your application. What impact are you seeing?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] aharui commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
aharui commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-598007941
The example source is throwing a caught exception in the binding code because the list of items is never initialized.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [royale-asjs] nihavend commented on issue #755: Binding function is
called after the static function in component
Posted by GitBox <gi...@apache.org>.
nihavend commented on issue #755: Binding function is called after the static function in component
URL: https://github.com/apache/royale-asjs/issues/755#issuecomment-598013924
Sorry @aharui, I checked the flex version the list was defined as native flat in class and was not a function. I had missed that point while porting to Royale and putting initializing into function.
Can we say that 4 times call is not an issue ?
Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services