Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
KetanS #1
Data not working on Label but is working in Datagrid
I am creating a simple website in Flex. I want to show different content from
the database for home, about us, contact us, etc. I am using a CFC as a
webservice to display the data depending on which link user clicks on.
The problem is that when I display the data through Label or Text, it is not
displaying anything, nor giving any error. But when I display the same data in
a datagrid, it works fine.
Can any body help me sort out this proble?
Here is how the table looks:
contentID contentCode content title
--------------------------------------------------------------------------------
----------------------------------------
1 home This is my Home page
content. Home
2 aboutus This is my About Us page
content. About Us
3 contactus This is my Contact Us page
content. Contact Us
4 privacy This is my Privacy
Policy page content. Privacy Policy
5 return This is my Return
Policy page content. Return Policy
Here is my code...
<!-- index.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
initialize="srv.getContent('home')" backgroundColor="#FFFFFF" marginTop="0"
marginBottom="0" height="100%" pageTitle="mySite">
<mx:Script>
<![CDATA[
var contentDesc: Object;
function getlink()
{
//getURL(String(event.data).toLowerCase(), '_blank')
}
]]>
</mx:Script>
<mx:WebService id="srv" wsdl="http://localhost/mySite/content.cfc?wsdl">
<mx:operation name="getContent" result="contentDesc=event.result" />
</mx:WebService>
<mx:HBox id="header" borderStyle="inset" borderColor="#000000"
horizontalAlign="center" verticalAlign="middle"
width="100%" height="{topimg.height+5}" marginTop="0" marginBottom="0"
backgroundColor="#EEE3C1">
<mx:Image id="topimg" source="images/topbanner.jpg" height="132" />
</mx:HBox>
<mx:HBox horizontalAlign="center" width="100%" height="100%" marginTop="0"
marginBottom="0">
<mx:VBox borderStyle="inset" width="10%" height="100%" marginTop="0"
marginBottom="0" backgroundColor="#EEE3C1" >
<!-- <mx:LinkBar direction="vertical" width="100%" dataProvider="linklist"
click="getURL(String(event.label).toLowerCase(), '_blank')" textAlign="center"
color="#993333" /> -->
<mx:Link label="Home" click="srv.getContent('home')" color="#990000" />
<mx:Link label="About us" click="srv.getContent('aboutus')" color="#990000"
/>
<mx:Link label="Contact us" click="srv.getContent('contactus')"
color="#990000" />
<mx:Link label="Products" click="getURL('products.mxml', '_blank')"
color="#990000" />
</mx:VBox>
<mx:VBox width="90%" marginTop="0" marginBottom="0" height="100%">
<mx:HBox height="100%" width="100%">
<mx:Label text="{contentDesc.title}" />
<mx:Text text="{contentDesc.content}" />
</mx:HBox>
<mx:DataGrid id="dg" dataProvider="{contentDesc}" width="100%">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Title" columnName="title" width="100"
/>
<mx:DataGridColumn headerText="Content" columnName="content"
width="350" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:HBox>
<mx:HBox borderStyle="inset" borderColor="#000000" horizontalAlign="right"
verticalAlign="middle" width="100%" height="25"
marginTop="0" marginBottom="0" backgroundColor="#EEE3C1" >
<mx:Link label="Privacy Policy " click="srv.getContent('privacy')"
color="#990000" />
<mx:Link label="* Return Policy " click="srv.getContent('return')"
color="#990000" />
<mx:Label text="* Copyright @ 2005" color="#993333" />
</mx:HBox>
</mx:Application>
================================================== ==============================
======
<!-- content.cfc -->
<cfcomponent displayname="ContentService" hint="This component retrieves
different contents" output="no">
<cffunction name="getContent" returntype="array" access="remote"
displayname="getContent" hint="This function retrieves content depending on a
value.">
<cfargument name="contentCode" required="yes" default="0" type="string">
<cfquery name="rsContent" datasource="mySite">
select * from contents
where contentCode = '#contentCode#'
</cfquery>
<cfset contentArr = ArrayNew(1)>
<cfoutput query="rsContent">
<cfset object = structNew()>
<cfset setval = structInsert(object, "contentID", contentID)>
<cfset setval = structInsert(object, "contentCode", contentCode)>
<cfset setval = structInsert(object, "content", content)>
<cfset setval = structInsert(object, "title", title)>
<cfset setval = ArrayAppend(contentArr, object)>
</cfoutput>
<cfreturn contentArr>
</cffunction>
</cfcomponent>
KetanS Guest
-
#38816 [Opn]: PHP code that was working perfectly recently stopped working.
ID: 38816 User updated by: mtoohee at gmail dot com -Summary: PHP code that was working perfectly recently stopped.... -
working with xml data
Hi! I'm new to Flex 2.0 so please help me out. I'm trying to build a simple flex application which excepts user&pass which is then send via... -
Macromedia Flash Player installed and working properly suddenlys stops working..
No idea what has caused the Flash player to stop working. This is not my machine but a relatives who has asked for help over the T'giving... -
Why is my Paging not working in my DataGrid?
Question: Why can't I enable paging in Datagrid? Answer: You must check 'AllowPaging' You must add code to handle the PageIndexChanged Event. ... -
Working TableStyle Not Working on a Second DataGrid
I am having difficulty getting Tablestyles to work on a datagrid. I have 2 datasets, 1 filled and the other not. The first contains customer, stock... -
ntsiii #2
Re: Data not working on Label but is working in Datagrid
Everything looks ok.
For debugging, create a result handler function, call it instead of setting
the global variable directly, so you can inspect the result object.
One guess, try contentDesc=event.result[0].
Tracy
ntsiii Guest
-
KetanS #3
Re: Data not working on Label but is working in Datagrid
Thanks Tracy.
event.result[0] worked. :)
As per your advice from now onward, I will use a result handler function
instead of direct assignment.
Can I display HTML content? I want to give user a WYSIWYG HTML editor in the
backend and store the content in the database which I want to show in the Flex
website. Can this be possible? The content will be having all kinds of HTML
tags.
Thanks again.
Ketan
KetanS Guest
-
ntsiii #4
Re: Data not working on Label but is working in Datagrid
Most of the text controls have an "htmlText" property, BUT, it only supports a
tiny subset of markup.
If you must have full html rendering you will need to use a trick with an
IFrame. See the link below for a sample app and the source code. It is hacky,
but it looks great, and is not hard to do.
[url]http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&object ID=185[/url]
Tracy
ntsiii Guest
-
KetanS #5
Re: Data not working on Label but is working in Datagrid
Thanks again Tracy,
I am looking exactly the same which is given in the link provided by you. I
will go through the code to understand it and try to implement it in my code.
Thanks again.
Ketan
KetanS Guest



Reply With Quote

