Data not working on Label but is working in Datagrid

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. #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....
    2. 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...
    3. 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...
    4. 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. ...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139