Model is compile time object, which means you can only mention source on
compile time. If you want to load different XML on runtime, you should use
HTTPService instead. What I understand from your code is, you are loading an
xml into a Model and binding Model to MenuBar's dataProvider.
Following is a quick example, that allows to load two different xml data for
MenuBar. You can see, how HTTPService is able to load xml files on runtime
and result is bound to MenuBar dataProvider.
You can find the attached file, place in flex application directory and run
the HTTPServiceExample.mxml.
1) ##HTTPServiceExample.mxml##
?xml version=1.0 encoding=iso-8859-1?
mx:Application width=800 height=600
xmlns:mx=http://www.macromedia.com/2003/mxml;
mx:Script
![CDATA[
function loadMenudata1()
{
service.url = menudata1.xml;
service.send();
}
function loadMenudata2()
{
service.url = menudata2.xml;
service.send();
}
]]
/mx:Script
mx:HTTPService id=service resultFormat=object url=
useProxy=false/mx:HTTPService
mx:MenuBar dataProvider={service.result}/mx:MenuBar
mx:Button label=load menudata1 click=loadMenudata1()/
mx:Button label=load menudata2 click=loadMenudata2()/
/mx:Application
2) ##menudata1.xml##
menuitem label=MenuItem A
menuitem label=SubMenuItem 1-A /
menuitem label=SubMenuItem 2-A /
/menuitem
3) ##menudata2.xml##
menuitem label=MenuItem B
menuitem label=SubMenuItem 1-B /
menuitem label=SubMenuItem 2-B /
/menuitem
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 27, 2005 11:53 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Data Model
hai!
I dont get ur solution.. I am already using a remote object as a data
service.. How should i use a http service in this case? cn u help me with
some code... I am very new to flex thats y i keep buging u a lot.. sorry for
this..
regards,
nithya
Matt Chotin [EMAIL PROTECTED] wrote:
Sorry for not answering sooner. You should look into using the
HTTPService instead of a Model in this case. HTTPService can decode XML
into an object structure but does it dynamically instead of statically like
the Model does.
Matt
From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED]
Sent: Thursday, April 21, 2005 10:57 PM
To: flexcoders
Subject: [flexcoders] Data Model
Hai,
I have a problem with the data model source. I have a model
which provides data for a menubar.. the source i of the model hard coded..
But i want it to change dynamically during run time.. how can i do this? can
i give something like
mx:Model id=theXML
source=../WEB-INF/Classes/com/jp/amway/shopping/Products/{subcatList.curren
tItem.name}.xml/
please help me with the code..
right now the code i am using is:
?xml version=1.0 encoding=utf-8?
mx:Panel xmlns:mx=http://www.macromedia.com/2003/mxml;
width=100% height=500
mx:Script
![CDATA[
var dataObject : Object;
]]
function labelFunc(item) : String
{
return item.getProperty(Name);
}
/mx:Script
mx:Model id=theXML
source=../WEB-INF/Classes/com/jp/amway/shopping/Products/cat_Artistry.xml/
mx:MenuBar id=menu1 width=100% dataProvider={theXML}
labelFunction=labelFunc mouseDown=event.menuItem.attributes.label/
/mx:Panel
Yahoo! Messenger
http://uk.rd.yahoo.com/mail/tagline_messenger/*http:/uk.messenger.yahoo.com
- Communicate instantly...Ping your friends today! Download Messenger
Now
http://uk.rd.yahoo.com/mail/tagline_messenger/*http:/uk.messenger.yahoo.com
/download/index.html
Yahoo! Messenger
http://uk.rd.yahoo.com/mail/tagline_messenger/*http://uk.messenger.yahoo.co
m - Communicate instantly...Ping your friends today! Download Messenger
Now
http://uk.rd.yahoo.com/mail/tagline_messenger/*http://uk.messenger.yahoo.co
m/download/index.html
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
http://docs.yahoo.com/info/terms/ .
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group