hai,
Abdul, in tried running ur code. But item doesnt get added to the cart. I dont understand the reason. pls can u help? this is very urgent.
Is there any other way of doing it? help me with the code..
Regards,
nithya
Abdul Qabiz <[EMAIL PROTECTED]> wrote:
Abdul Qabiz <[EMAIL PROTECTED]> wrote:
Hi Nithya,Both of Flex applications can communicate using LocalConnection. See the modified code below:1) ##app.mxml##<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*" initialize="onAppInit()"
creationComplete="iFrame.visible=true">
<mx:Script>
<![CDATA[
var receiving_lc:LocalConnection;
function onAppInit()
{
receiving_lc = new LocalConnection();
receiving_lc.addItemToCart = mx.utils.Delegate.create(this, addItemToCart);
receiving_lc.connect("cartConnection");
}
function addItemToCart(itemObj)
{
cart.addItem(itemObj);
}
]]>
</mx:Script>
<mx:Model id="catalog" source="catalog.xml"/>
<mx:HBox width="100%" height="100%"><mx:Panel title="Tile" width="350" height="100%" panelBorderStyle="roundCorners">
<mx:TileList id="tile"
dataProvider="{catalog.product}"
width="100%"
height="100%"
cellRenderer="Thumbnail"
itemWidth="120"
itemHeight="108" change="iFrame.source=tile.selectedItem.path"/><mx:DataGrid id="cart" dataProvider="{catalog.product}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="name" headerText="Name"/>
<mx:DataGridColumn columnName="price" headerText="Price"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Panel><mx:Panel title="Content" width="400" height="100%" marginTop="1" marginBottom="1" marginLeft="1" marginRight="1">
<IFrame id="iFrame" width="100%" height="100%"/>
<mx:ControlBar>
<mx:CheckBox id="cbVisible" label="IFrame Visible" selected="true" click="iFrame.visible=cbVisible.selected"/>
</mx:ControlBar>
</mx:Panel></mx:HBox></mx:Application>2) ##popup.jsp##<%@ taglib uri="FlexTagLib" prefix="mm"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Product Detail</title>
</head><body>
<mm:mxml border="1">
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" initialize="onAppInit()">
<mx:Script>
var cart;
var _lc:LocalConnection;
function onAppInit()
{
_lc = new LocalConnection();
}
function addRow() {
//if (name.text != "") cart.addItem( {name: name.text, orderno: orderno.text} );
if(name.text != "") _lc.send("cartConnection", "addItemToCart", {name: name.text, orderno: orderno.text});
}
</mx:Script><mx:VBox>
<mx:Text id="name" text="Prod 1" />
<mx:Text id="orderno" text="#0011"/>
<mx:Button label="Add" click="addRow()"/>
</mx:VBox>
</mx:Application>
</mm:mxml>
</body>
</html>Also check out LocalConnection documentation for more help.Hope that helps...-abdul
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of nithya karthik
Sent: Saturday, June 11, 2005 12:04 PM
To: flexcoders
Subject: [flexcoders] passing data from jsp page to flex apphai, i have a flex appl that would call a jsp page. in the jsp page i have an embedded mxml witha button "add". when i trigger that it must get added to my mxml page outside jsp page. how to do this? my code is as below:mxml:<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"
creationComplete="iFrame.visible=true">
<mx:Model id="catalog" source="catalog.xml"/>
<mx:HBox width="100%" height="100%"><mx:Panel title="Tile" width="350" height="100%" panelBorderStyle="roundCorners">
<mx:TileList id="tile"
dataProvider="{catalog.product}"
width="100%"
height="100%"
cellRenderer="Thumbnail"
itemWidth="120"
itemHeight="108" change="iFrame.source=tile.selectedItem.path"/><mx:DataGrid id="cart" dataProvider="{catalog.product}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="name" headerText="Name"/>
<mx:DataGridColumn columnName="price" headerText="Price"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Panel><mx:Panel title="Content" width="400" height="100%" marginTop="1" marginBottom="1" marginLeft="1" marginRight="1">
<IFrame id="iFrame" width="100%" height="100%"/>
<mx:ControlBar>
<mx:CheckBox id="cbVisible" label="IFrame Visible" selected="true" click="iFrame.visible=cbVisible.selected"/>
</mx:ControlBar>
</mx:Panel></mx:HBox></mx:Application>Jsp code:<%@ taglib uri="FlexTagLib" prefix="mm"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Product Detail</title>
</head><body>
<mm:mxml border="1">
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
var cart;
function addRow() {
if (name.text != "") cart.addItem( {name: name.text, orderno: orderno.text} );
}
</mx:Script><mx:VBox>
<mx:Text id="name" text="Prod 1" />
<mx:Text id="orderno" text="#0011"/>
<mx:Button label="Add" click="addRow()"/>
</mx:VBox>
</mx:Application>
</mm:mxml>
</body>
</html>When i click on the add button in jsp page it should get added in my flex datagrid outisde the jsp page. I dont know how i shoule refer to the grid. pls help.Send instant messages to your online friends http://uk.messenger.yahoo.com
Send instant messages to your online friends http://uk.messenger.yahoo.com
Yahoo! Groups Links
http://groups.yahoo.com/group/flexcoders/
[EMAIL PROTECTED]