================================================================================ ====== select * from contents where contentCode = '#contentCode#' [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => KetanS [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Data not working on Label but is working in Datagrid - Macromedia Flex General Discussion

Data not working on Label but is working in Datagrid - Macromedia Flex General Discussion

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 ...

  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. #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

  3. #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

  4. #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

  5. #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

Similar Threads

  1. #38816 [Opn]: PHP code that was working perfectly recently stopped working.
    By mtoohee at gmail dot com in forum PHP Programming
    Replies: 0
    Last Post: September 13th, 09:41 PM
  2. working with xml data
    By Iztok in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: June 21st, 05:05 PM
  3. Replies: 0
    Last Post: November 26th, 06:47 AM
  4. Working TableStyle Not Working on a Second DataGrid
    By psibertrip in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: May 7th, 04:57 PM
  5. Focus in Datagrid not working
    By Purdy in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: December 10th, 02:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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