Data between mxml components
I have a question about data between mxml components.
Product.mxml is the overview screen for the products and ProductDetail.mxml (it is a TitleWindow) the detail screen.
In the Product I define a value object ProductVo with all the data. When I click a record in the overview and click the button 'change' (changeProduct function) then a popup window appears with all the data in it.
Code in Product.mxml:
[Bindable]
public var myWin:ProductDatail;
private function changeProduct():void {
myWin = PopUpManager.createPopUp(this, ProductDetail, true) as ProductDetail;
myWin["btnSave"].addEventListener("click", save);
private function save(event:Event):void {
productVo.productId = myWin.ti_productnr.text;
productVo.name = myWin.ti_name.text;
productVo.ean = myWin.ti_ean.text;
...some code to save the data in the db...
Code in ProductDetail.mxml:
[Bindable]
public var productDetailVo:ProductVo;
<mx:Form>
<mx:FormItem label="Productnr" required="true">
<mx:TextInput id="ti_productnr" text="{productDetailVo.productId}" width="60"/>
</mx:FormItem>
<mx:FormItem label="Naam" required="true">
<mx:TextInput id="ti_name" text="{productDetailVo.name}" width="200"/>
</mx:FormItem>
<mx:FormItem label="Ean">
<mx:TextInput id="ti_ean" text="{productDetailVo.ean}" width="100"/>
</mx:FormItem>
<mx:FormItem direction="horizontal">
<mx:Button id="btnSave" label="Save"/>
</mx:FormItem>
</mx:Form>
So my question: the save function in Product.mxml, is it possible to do this in a easier way instead of linking all the data from the form into the value object? Something like productVo = myWin.productDetailVo, but that does not work.
I just looked at the parsley framework and saw this code:
private function save():void
contact.firstName = firstName.text;
contact.lastName = lastName.text;
contact.email = email.text;
service.save(contact);
So, it is doing the same thing I'm doing.
I'm using Spring and hibernate on the server level, it is my own framework.
Similar Messages
-
Best method for passing data between nested components
I have a fairly good sized Flex application (if it was
stuffed all into one file--which it used to be--it would be about
3-4k lines of code). I have since started breaking it up into
components and abstracting logic to make it easier to write,
manage, and develop.
The biggest thing that I'm running into is figuring out a way
to pass data between components. Now, I know how to write and use
custom events, so that you dispatch events up the chain of
components, but it seems like that only works one way (bottom-up).
I also know how to make public variables/functions inside the
component and then the caller can just assign that variable or call
that function.
Let's say that I have the following chain of components:
Component A
--Component B
-- -- Component C
-- -- -- Component D
What is the best way to pass data between A and D (in both
directions)?
If I use an event to pass from D to A, it seems as though I
have to write event code in each of the components and do the
bubbling up manually. What I'm really stuck on though, is how to
get data from A to D.
I have a remote object in Component A that goes out and gets
some data from the server, and most all of the other components all
rely on whatever was returned -- so what is the best way to be able
to "share" data between all components? I don't want to have to
pass a variable through B and C just so that D can get it, but I
also don't want to make D go and request the information itself. B
and C might not need the data, so it seems stupid to have to make
it be aware of it.
Any ideas? I hope that my explanation is clear enough...
Thanks.
-JakePeter (or anyone else)...
To take this example to the next (albeit parallel) level, how
would you go about creating a class that will let you just
capture/dispatch local data changes? Following along my original
example (Components A-D),let's say that we have this component
architecture:
Component A
--Component B
-- -- Component C
-- -- -- Component D
-- -- Component E
-- -- Comonnent F
How would we go about creating a dispatch scheme for getting
data between Component C and E/F? Maybe in Component C the user
picks a username from a combo box. That selection will drive some
changes in Component E (like triggering a new screen to appear
based on the user). There are no remote methods at play with this
example, just a simple update of a username that's all contained
within the Flex app.
I tried mimicking the technique that we used for the
RemoteObject methods, but things are a bit different this time
around because we're not making a trip to the server. I just want
to be able to register Component E to listen for an event that
would indicate that some data has changed.
Now, once again, I know that I can bubble that information up
to A and then back down to E, but that's sloppy... There has to be
a similar approach to broadcasting events across the entire
application, right?
Here's what I started to come up with so far:
[Event(name="selectUsername", type="CustomEvent")]
public class LocalData extends EventDispatcher
private static var _self:LocalData;
// Constructor
public function LocalData() {
// ?? does anything go here ??
// Returns the singleton instance of this class.
public static function getInstance():LocalData {
if( _self == null ) {
_self = new LocalData();
return _self;
// public method that can be called to dispatch the event.
public static function selectUsername(userObj:Object):void {
dispatchEvent(new CustomEvent(userObj, "selectUsername"));
Then, in the component that wants to dispatch the event, we
do this:
LocalData.selectUsername([some object]);
And in the component that wants to listen for the event:
LocalData.getInstance().addEventListener("selectUsername",
selectUsername_Result);
public function selectUsername_Result(e:CustomEvent):void {
// handle results here
The problem with this is that when I go to compile it, it
doesn't like my use of "dispatchEvent" inside that public static
method. Tells me, "Call to possibly undefined method
"dispatchEvent". Huh? Why would it be undefined?
Does it make sense with where I'm going?
Any help is greatly appreciated.
Thanks!
-Jacob -
Dispatch text between mxml components
Hi all,
i was just trying to pass some string to an mxml component
and i have been having a hard time i am relatively new to flex and
what i want to do is simply pass a user id string to this component
in order to retrieve data specific to this user can someone help me
out?
Thanks a lot. : )Simple declare the namespace where the file is located and create an instance of the component in the primary app.
If in the same folder as the main app MXML file:
xmlns:comp="*" where comp can be anything (myComponents, components, etc.)
If a sub-folder "components" of the main app MXML file:
xmlns:comp="components.*" where comp can be anything (myComponents, components, etc.)
<comp:MyFancyComponent id="myComp"/> declare an instance of the component.
Then do this:
myAppVar = myComp.myCompVar; -
How to make link between xcelsius components with sap data using Web servic
Hi all,
I have a doubt regarding connection between Xcelsius components and SAP data.
I created one Web service using Function module and made a connection between xcelsius and that web service using binding URL. It shows imput and output parameters perfectly.
But I cant get any idea as to how to connect Xcelsius components with these parameters.
Can anybody help me out..
please its urgent.
Thanks,
SimadriHave you bound your output parameters to ranges of cells? Select the item, then click the icon to the right of the Insert In: box and select the cells.
Add a spreadsheet component to your chart and bind it to the cells, then preview the model. Do you see the data coming through?
If you do, then you can click File > Snapshot > Export Excel Data. Then close Preview mode, and import data from spreadsheet and select the sheet you just exported. This gives you real data to work with when designing the dashboard.
Hope that helps. -
How to pass data between components?
Hi everyone,
How can I pass data between components? If possible, please
give me sample code. Thanks.
Note: I am using Flex 3.
MayThere are lots of examples in the doc. You can start here:
http://livedocs.adobe.com/flex/3/html/mxmlcomponents_advanced_1.html
Stephen -
Sharing static data between all WD components
Hello
I'm looking for a way to share static data between all WD sessions of a WD application. Static data is static (language depended) value lists for instance. How can this be done in WD for ABAP?
Is this recommended at all?
Regards, MathiasHi,
if these lists are static, you can use z-tables with in the key a 'spras' field.
do the selection while loading the application with sy-langu on those tables to fetch the language dependant lists
(example table makt, for material descriptions)
if you mean you want to share these data between several wda components of 1 application,
you should use the same assistance class in all of them and fetch the data in the main component to store it in the assistance class.
this class will be instantiated and all the other components will have access to the data (instance will be recognized automatically as of SP11)
grtz,
Koen
Edited by: Koen Labie on Mar 6, 2008 5:06 PM -
How data transfered between two components in FPM. - SRM Shoppingcart
Hi Guys,
I have requirement for SRM Shoppingcart.. to add new column in /SAPSRM/WDC_UI_SC_DOTC_BD (Item Overview Table) component and to populate the data from this column into /SAPSRM/WDC_DODC_NA (Item Details Tabs) component Notes and attachment text column. (View - V_DODC_NOTES)
I dont find any component usage or Link between these components.
Application - /SAPSRM/WDA_L_FPM_OIF
Could you please provide the outline of what has to been to transfer data between the two components.
This is an enhancement to std. SAP shopping cart process. - Is this enhancement possible ?
Cheers
Sam
Edited by: samraj001 on Dec 7, 2010 4:47 AMHi,
Can you resolvre these problem.. I have the same situation.. If you can resolveit, can you helpme??
Thanks...!!! -
Revision: 11192
Author: [email protected]
Date: 2009-10-27 12:54:37 -0700 (Tue, 27 Oct 2009)
Log Message:
In AIR, you can drag'n drop text between text components like TextInput and TextArea. There's an AIR bug where doing so doesn't result in a TEXT_INPUT or a CHANGE event. This is a workaround for that bug so that we listen for a nativeDragDrop event.
QE notes: -
Doc notes: -
Bugs: SDK-19816
Reviewer: Gordon
Tests run: checkintests, mustella TextInput, TextArea
Is noteworthy for integration: no
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-19816
Modified Paths:
flex/sdk/branches/3.x/frameworks/projects/framework/src/mx/controls/TextArea.as
flex/sdk/branches/3.x/frameworks/projects/framework/src/mx/controls/TextInput.asFirst 3 .as are the component
source. in the last test.mxml file i have written the drag and drop functionality.
can any help me?? please -
How to use a context between two components at the runtime
Hi Experts,
My Web dynpro component is over the Generation limit (size of generated load is > 2 MB) so it always gets Warning when I active it. That why I have separated my application into two components and use the ViewContainerUIElement in order to show views of each other.
In the application, I use also the TimeTrigger to refresh pages, all views have a TimeTrigger and the DELAY property of TimeTriggers is bounden into the same context attribute. I use a component to set up (change) the value of context attribute that is mapped with the Delay property. I want to change the Delay value on a component and other component will understand the changing.
My problem is how I can use the same context attribute between components at the runtime?
Let give me your advice on this.
Many thanks,
KenHi Ken,
You can use [external context mapping|https://cw.sdn.sap.com/cw/docs/DOC-27901] to share data between two or more components using context.
Thanks,
Duy -
Passing data to parent components
Howdy folks,
I'm basically attempting to pass data between components.
Passing data from a parent component to a child component is easy
enough but I have run into a few problems with attempting the
opposite.
Goal :-
In more detail, I have the parent component which contains an
accordian. Each accordian pane is a component within itself. The
first accordian pane is a search component that users can search
for a customer's site address and make a selection from a data
grid. When a user selects a customer from the grid, I wish to pass
the Site ID of that selection to the second accordian pane to
display that sites full details.
Problem :-
The way in which I have attempted to do this is by passing
the selection (the site ID) to a bindable variable (called SiteID)
in the parent component which contains the accordian (using
parent.SiteID = event.currentTarget.selectedItem.SiteID) to then
pass it to the second accordian pane where the site's details can
be displayed but I get an "Undefined property" error.
I believe a way to do this is by using a custom event for the
search component but I am hoping there is a more straight forward
way to do this.
Any help would be greatly appreciated.
Many thanks.I think events are the best approach to your problem, you
could also use the
parent or
parentApplication properties to acces the parent component.
I think you can use Application.application and that one references
your parent application too.
I will insist that using events is the best solution, but
feel free to try the other solutions
Hope it helps u out -
Best way to transfer single point data between loops on FPGA
Hi,
I used quite number of loops on FPGA and need to transfer single point datas between loops. Only the current value of data is needed so buffer is not necessary. I don't want use target scope FIFO since it require minimum 21 elements and I only need the current value. Is there other way other than local variables?
Thanks for help!
Regards,
TomHi Godel,
Since this discussion thread is over 3 years old, it would be better to start a new thread with your specific questions to get quicker help.
I did a bit of research on your question, and found this helpful White Paper (http://www.ni.com/white-paper/7727/en/) that discusses the resources used for components in LV FPGA code. For local variables (although it depends on hardware), it looks like it uses Flip-flops and LUTs.
As for using local variables with different clock rates, I found this KnowledgeBase article that might help shed some light on your question - some issues can arise from using them with more than one clock rate (http://digital.ni.com/public.nsf/allkb/C683585460E88508862570D1006B7434)
Hope this helps! Again, if you have follow-up questions, I would definitely recommend creating a new thread
Xavier
Applications Engineering Specialist
National Instruments -
Exchanging data between different browser windows
Hi,
It´s possible to eschange data between iviews that are in diferrent browser windows, using databag or Portal event functions?
I want do save data in Databag or fire a event in Webdynpro application. After it, another application (webdynpro for java) will execute in another browser window, reading the databag or handling the event.
Both the application are in the Portal.
Thanks,
MárcioShould be possible if you can read & write to cookie from the application. Assuming both the instances are running on the same system.
If you are using Portal Components ( JSPDynpage etc) then you can declare USER SPECIFIC personalization properties & this can store data . Since its personalized is can be read only by the logged in user, from either browsers.
Greetings
Prashant -
Using salesforce connector in multiple mxml components
I am using Flex 2.0.1 and Salesforce as Database. My question
is i am creating login method in each component and application. I
want to use/pass salesforce connection from main application to all
sub component, how can i achieve this to avoid login for each
application/ component.
example: In my project i created main.mxml application and 3
mxml components in each component i am logining into the salesforce
database to retrieve data from the database. i want to avoid
creating multiple logins for the components instead of writing
login for each mxml component i want login for the first time in
main.mxml application and want to use the same connection in mxml
components. Can anyone tell me how can i achieve this
If you feel this is not sufficient information to solve this
problem then let me know i will post another message with sample
code.
Thanks in advance.The solution I ended up using was just to reference the CSS file at the root MXML application. Then I could just use .styleName on the Menu component and voila, it worked.
-
Dynamically add custom MXML components in Actionscript
As there's no constructor for custom MXML components, how to
dynamically add it as a child using ActionScript?
I'm looking for some alternative to avoid the need to rewrite
the entire existent component in ActionScript just to add it this
feature (a constructor). PopManager is not an alternative...
Is there any way?
The case/situation:
I have a custom MXML component that needs to be dinamically
added to a NativeWindow created using ActionScript.
Thanks a lot!
Vicente Junior
Independent Web Developer
http://teclandoalto.blogspot.commxml classes get generated into AS classes with a default
constructor.
In fact, there is essentially no difference between an AS
component and an mxml component, they can be used exactly the same
way.
Tracy -
Architecting an Application With MXML Components
I have an application that has gotten lengthy and I want to
simplify it by architecting the Main Application with custom MXML
Components. The application as it is currently architected works
perfectly.
Currently, the application consists of "Canvas" containers
along Top and Left Side holding Navigation Buttons. The main
(changing) sections of the application will consist of a
"ViewStack" container holding a number of "Canvas" containers
stacked on top of one another. The navigation buttons along the top
and left side, when clicked, display in turn the content of each of
the several stacked "Canvas" containers. Because of the number of
stacked "Canvas" containers within the "ViewStack" and the content
of each, the main Application source code has become very long and
unwieldy, thus the need to use custom components for each of the
"Canvas" containers in the "Stack" and referencing them in the main
Application page.
I have tried several times to get this to work and I need to
clarify a couple of things.
1) After setting up custom components for the several
"Canvas" containers that are now in the "ViewStack" container, do I
first need to set up a custom component for the "ViewStack"
container with its own name space?
2) If the answer to 1) above is Yes then do I then reference
each of the custom components for the "Canvas" container with their
own name space designation within the "ViewStack" reference within
the main Application?
In the event I am completely off base then I would appreciate
any suggestions. If you wish I would be happy to email you the
current application page.
Thanks,
Joe
joe kHere is some code for an app built with components. You can
see how the pieces talk to each other a bit.
------------------------- ViewStack1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.*"
layout="vertical" width="100%" height="100%" >
<comp:TopBar />
<mx:HBox width="100%" height="100%">
<comp:LeftBar />
<mx:VBox width="100%" height="100%">
<mx:ViewStack id="myViewStack" borderStyle="none"
width="100%" height="100%">
<mx:VBox id="home" width="100%">
<comp:MainIntroText />
<mx:HRule width="50%" height="3"
strokeColor="0xCC3333"/>
<comp:MainSecondaryText />
<mx:HRule width="50%" height="3"
strokeColor="0xCC3333"/>
<comp:MainFinalText />
</mx:VBox>
<mx:VBox id="about" width="100%">
<comp:About />
</mx:VBox>
<mx:VBox id="contact" width="100%">
<comp:Contact />
</mx:VBox>
</mx:ViewStack>
</mx:VBox>
</mx:HBox>
</mx:Application>
------------------------------- About.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:VBox width="65%">
<mx:Text fontSize="14" width="100%" text="This page tells
you about us." />
</mx:VBox>
</mx:HBox>
----------------------------------- Contact.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:VBox width="65%">
<mx:Text fontSize="14" width="100%" text="This page tells
you how to contact us." />
</mx:VBox>
</mx:HBox>
------------------- LeftBar.mxml -------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="200" height="100%">
<mx:LinkButton label="Adobe Labs - Flex"
click="navigateToURL(new URLRequest('
http://labs.adobe.com/technologies/flex'),
'_blank');"/>
<mx:Spacer height="20"/>
<mx:Label fontSize="16" text="Flex Blogs"/>
<mx:LinkBar direction="vertical" width="90%"
itemClick="navigateToURL(new URLRequest(event.item.data),
'_blank');">
<mx:Object label="Adobe Flex Team Blog" data="
http://weblogs.macromedia.com/flexteam/"/>
<mx:Object label="Flex Blog Aggregator" data="
http://www.allyourflexarebelongtous.com/"/>
<mx:Object label="Adobe Flex Blog Aggregator" data="
http://weblogs.macromedia.com/mxna/index.cfm?query=byCategory&categoryId=5&categor yName=Flex"/>
</mx:LinkBar>
<mx:Spacer height="20"/>
<mx:Label fontSize="16" text="Example Flex Apps"/>
<mx:LinkBar direction="vertical" id="addlRscList"
width="90%" itemClick="navigateToURL(new
URLRequest(event.item.data), '_blank');">
<mx:Object label="Adobe Flex Store" data="
http://www.adobe.com/devnet/flex/samples/flex_store_v2/"/>
<mx:Object label="Adobe Dashboard Example" data="
http://examples.adobe.com/flex2/inproduct/sdk/dashboard/dashboard.html"/>
<mx:Object label="Buzzword Word Processor" data="
http://preview.getbuzzword.com/?s=true"/>
<mx:Object label="Adobe Style Explorer" data="
http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html"/>
<mx:Object label="Adobe Component Explorer" data="
http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html"/>
</mx:LinkBar>
</mx:VBox>
----------------------- MainFinalText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the final text I want to show you." />
</mx:VBox>
--------------------------- MainIntroText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the main text I want to show you." />
</mx:VBox>
----------------------- MainSecondaryText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the secondary text I want to show you." />
</mx:VBox>
--------------- TopBar.mxml --------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Script>
<![CDATA[
private function goToViews(view:String):void {
if(view == "home"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.home;
if(view == "about"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.about;
if(view == "contact"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.contact;
]]>
</mx:Script>
<mx:LinkButton label="MySnazzyLogo" fontSize="20"
click="goToViews('home');" />
<mx:VBox width="100%">
<mx:HBox width="100%">
<mx:Spacer width="100%" />
<mx:LinkBar fontSize="14"
itemClick="goToViews(String(event.item.data));">
<mx:Array>
<mx:Object label="About Us" data="about"/>
<mx:Object label="Contact Us" data="contact"/>
</mx:Array>
</mx:LinkBar>
</mx:HBox>
<mx:HBox width="100%">
<mx:Spacer width="150" />
<mx:Label fontSize="25" text="Here is Some Additional
Text" />
</mx:HBox>
</mx:VBox>
</mx:HBox>
Maybe you are looking for
-
Intel GMA 945: xrandr trouble
Hello everyone, I recently observed that when rotating the screen using xrandr -o, it becomes very dark. I'm on a Thinkpad X60 Tablet with Intel GMA 945 and up to date intel driver and Xorg. I have checked this on a laptop of the same model by a frie
-
ineed help!!!! i cant reinstall itunes with out the itunes 64 folder and i already deleteted every aspect of itunes from the computer!!!!!
-
Problems setting up PPP using GSM modem
I am trying to setup a PC with Solaris 10 installed to use a 3G USB modem to connect to the internet. bash-3.00# cat /etc/release Solaris 10 10/09 s10x_u8wos_08a X86 bash-3.00# uname -a SunOS gateway 5.10 Generic_141445-09 i86pc i386 i86pc I have the
-
Adobe after effects blue screen at "Intializing User Inferance"
Everytime i start up Adobe after effects cs4 i get a blue screen error at intializing user inferance. Can anyone help me with this? I have reinstalled after effects a couple times with no luck
-
Diffent durations and total floats in groupings
I recived a baseline schedule from a contractor which included a printout (barchat) and a electronic copy to import into my P6, however when i import the file i end up with different origina durations and total float in some of the groupings (not al