#31
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    <script>
    var dsArtist = new
    Spry.Data.XMLDataSet("ArtistDataManager.cfc?method=getArtist", "album/tracks/song");
    </script>
    <cfsprydataset
    name="dsTitle"
    type="xml"
    bind="CFC:ArtistDataManager.getArttitle(prodname={albumform:songgrid.TITLE})"
    xpath="album/tracks/song"
    options="{method: 'POST'}"
    onBindError="errorHandler">
  2. #32
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    <style type="text/css">
    <
    #FiltersList {
    height:20px;
    width: 20px;
    }>
    </style>
    </head>
    <body>
    <div id="FiltersList" spry:region="dsArtists" class="SpryHiddenRegion">
    <div spry:repeat="dsArtist" class="ListBoxItemGroup">
    <div class="ListBoxItem"
    onclick="dsArtist.setCurrentRow('{dsArtist::ds_RowID}');"
    spry:selectgroup="feedsList" spry:select="SelectedListBoxItem"
    spry:hover="ListBoxItemHover">
    {dsArtist::description}
    </div>
    </div>
    </div>

    <cfform name="albumform">
    <cfgrid name="songgrid"
    format="html"
    bind="CfC:ArtistDataManager.getData(page={cfgridpage},
    pageSize={cfgridpagesize},sortCol={cfgridsortcolumn},
    sortDir={cfgridsortdirection},filter={dsArtist.name})"
    selectMode="browse"
    width=400
    delete="true"
    pageSize=7>
    <cfgridcolumn name="TITLE" header="Name" width=200>
    <cfgridcolumn name="Artist" header="Type" width=200>
    </cfgrid><br />
    <cfinput name="artist" bind="{dsArtist.name}">
    </cfform>
    <hr>
    <div id="RSSResultsList" spry:detailregion="dsTitle" class="SpryHiddenRegion">
    <strong>{name}</strong><br>
    <div>{desc}</div>
    </div>
    <hr>
    </body>
    </html>
  4. #33
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    Ok i had to leave out the middle part of my code do to the message i was getting from the forum.

    The middle of my code contains:

    errorHandler = function(code,msg){
    alert("Error w/bind occurred. See details below:\n\n" + "Error Code: "
    + code + "\n" + "Error Message: " + msg);
    }



    and then its warpped in <script lang = "javascript></script>
  6. #34
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    The middle is in btw the 1st and the 2nd post of the code for the cfm and i realize i didn't copy the <html>, <head> tags but they are also apart of the code.
  8. #35
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    I would remove all of the AJAX stuff and just get it working with a normal form page and action page. Once that all works, then start adding the AJAX logic. You're trying to do to much at the same time.
  10. #36
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    ok i will need your assistance with this you say that you would remove all of the spry data. I have alot of binding going on within that data.

    I can remove it but I had some logic going on with it that kind of made since to me.

    So could you give me an example of how you would approach this?
  12. #37
  13. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Remove the AJAX stuff and just make a page that lists the artists and lets you enter a name, and a second page that displays the results of the search, using the same CFC to confirm that the CFC itself works correctly.
  14. #38
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    I stripped down my cfm page to the folllowing. Still i get that same messege.

    Is there something that I should be removing from my cfc page?

    cfm


    <html>

    <head>



    <cfform name="albumform">

    <cfgrid name="songgrid"
    format="html"
    bind="CfC:ArtistDataManager.getData(page={cfgridpage},
    pageSize={cfgridpagesize},sortCol={cfgridsortcolumn},
    sortDir={cfgridsortdirection})"
    selectMode="browse"
    width=400
    delete="true"
    pageSize=7>
    <cfgridcolumn name="TITLE" header="Name" width=200>
    <cfgridcolumn name="Artist" header="Type" width=200>
    </cfgrid><br />

    <cfinput name="artist">
    </cfform>


    cfc
    <cfcomponent name="ArtistDataManager">

    <cffunction name="getArtist" access="remote" output="false" returnFormat="plain">
    <cfhttp url="http://localhost:8500/interviewtest/music.xml">
    <cfset biggie = xmlparse ("#cfhttp.FileContent#")>
    <cfcontent type="text/xml" reset="yes">
    <cfreturn biggie>
    </cffunction>

    <cffunction name="getData" access="remote" output="false">
    <cfargument name="page" required="yes">
    <cfargument name="pageSize" required="yes">
    <cfargument name="sortCol" required="yes">
    <cfargument name="sortDir" required="yes">
    <cfargument name="filter" required="no">
    <cfhttp url="http://localhost:8500/interviewtest/music.xml">
    <cfset biggie = xmlparse ("#cfhttp.FileContent#")>
    <cfset txe = biggie.album.tracks.song>
    <cfset box = arraylen(txe)>
    <cfset myquery = QueryNew("title, artist")>
    <cfloop index="i" from = "1" to = #box#>
    <cfset temp = QuerySetCell (myquery, "artist", #biggie.album.tracks.song[i].artist.xmltext#, #i#)>
    <cfset temp = QuerySetCell (myquery, "title", #biggie.album.tracks.song[i].title.xmltext#, #i#)>
    </cfloop>
    <cfquery name="Search" datasource="myquery">
    select TITLE, ARTIST from SONG
    <<cfif isDefined("arguments.filter") AND arguments.filter NEQ "">
    where TRACKS = '#arguments.filter#'

    </cfif>
    <cfif arguments.sortCol NEQ "" AND arguments.sortDir NEQ "">
    order by #arguments.sortCol# #arguments.sortDir#
    <cfelse>
    order by TITLE ASC
    </cfif>
    </cfquery>

    cfreturn QueryConvertForGrid(Search, arguments.page,
    arguments.pageSize)>
    </cffunction>

    <cffunction name="getArttitle" access="remote" output="false">
    <cfargument name="prodname" default="The Song">

    <cfquery name="SongDetails" datasource="myquery">
    select TITLE, ARTIST from SONG
    where TITLE = '#arguments.prodname#'
    </cfquery>
    <cfoutput>
    <cfxml variable="MUSICXML" >
    <?xml version="1.0" encoding="iso-8859-1"?>
    <album>
    <title>Questions, unanswered</title>
    <artist>Steve and the flubberblubs</artist>
    <year>1989</year>
    <tracks>
    <song tracknumber="1" length="4:05">
    <title>What do you know?</title>
    <artist>Steve and the flubberblubs</artist>
    <lastplayed>2006-10-17-08:31</lastplayed>
    </song>
    <song tracknumber="2" length="3:45">
    <title>Who do you know?</title>
    <artist>Steve and the flubberblubs</artist>
    <lastplayed>2006-10-17-08:35</lastplayed>
    </song>
    <song tracknumber="3" length="5:14">
    <title>When do you know?</title>
    <artist>Steve and the flubberblubs</artist>
    <lastplayed>2006-10-17-08:39</lastplayed>
    </song>
    <song tracknumber="4" length="4:19">
    <title>Do you know?</title>
    <artist>Steve and the flubberblubs</artist>
    <lastplayed>2006-10-17-08:44</lastplayed>
    </song>
    </tracks>
    </album>
    </cfxml>
    </cfoutput>
    <!--- Convert the XML object to an XML string. --->
    <cfset xmldata = xmlparse(musicxml)>
    <cfcontent type="text/xml" reset="yes">
    <cfreturn xmldata>
    </cffunction>

    </cfcomponent>





    </body>
    </html>
  16. #39
  17. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    It means you still have an error in your CFC somewhere. You also still have not removed the AJAX code, which is only going to make it harder for you to debug.
  18. #40
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    ok I have taken my CFC down to this.

    What I am trying to do in this cffunction is to define a data source by making a query of my parsed xml. From there I am aslo making a qurey to fill in the columns of my cfgrid.

    Am I going about this the correct way?

    <cfcomponent name=ArtistSearch output=false>



    <cffunction name="getdata" access="remote" returntype="string">
    <cfhttp url="http://localhost:8500/interviewtest/music.xml">
    <cfset xmlmusic = xmlparse("#cfhttp.FileContent#")>
    <cfset txe = biggie.album.tracks.song>
    <cfset box = arraylen(txe)>
    <cfset myquery = QueryNew("title, artist")>
    <cfset temp = QueryAddRow(myquery, #box#)>
    <cfloop index="i" from = "1" to = #box#>
    <cfset temp = QuerySetCell (myquery, "title", #biggie.album.tracks.song[i].title.xmltext#, #i#)>
    <cfset temp = QuerySetCell (myquery, "artist", #biggie.album.tracks.song[i].artist.xmltext#, #i#)>
    </cfloop>
    <cfquery name="Search" datasource="myquery">
    select TITLE, ARTIST from SONG
    <cfif isDefined("txe") >
    where artist = '#txe#'
    </cfif>

    </cffunction>



    </cfcomponent>
  20. #41
  21. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Are you getting an error? If so, what is it? You've really got to post details, asking "is this correct" is the wrong question. Only you know if it is correct, because if it isn't, you should be getting an error.

    In your code I see nothing creating a variable called "biggie". Use cfdump and cfabort to ensure that the variable(s) you're working with actually contain the data that you think they do.
  22. #42
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    Invalid CFML Construction on line 1 at column 1.




    <cfcomponent name="ArtistSearch" output="false">



    <cffunction name="getdata" access="remote" returntype="string">
    <cfhttp url="http://localhost:8500/interviewtest/music.xml">
    <cfset biggie = xmlparse("#cfhttp.FileContent#")>
    <cfset txe = biggie.album.tracks.song>
    <cfset box = arraylen(txe)>
    <cfset myquery = QueryNew("title, artist")>
    <cfset temp = QueryAddRow(myquery, #box#)>
    <cfloop index="i" from = "1" to = #box#>
    <cfset temp = QuerySetCell (myquery, "title", #biggie.album.tracks.song[i].title.xmltext#, #i#)>
    <cfset temp = QuerySetCell (myquery, "artist", #biggie.album.tracks.song[i].artist.xmltext#, #i#)>
    </cfloop>
    <cfquery name="Search" datasource="myquery">
    select TITLE, ARTIST from SONG
    <cfif isDefined("txe") >
    where artist = '#txe#'
    </cfif>
    </cfquery>

    </cffunction>



    </cfcomponent>
  24. #43
  25. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    If line one of the file in the error is:

    <cfcomponent name="ArtistSearch" output="false">

    I see nothing wrong with it.

    Which to me means that you're not looking at the right file. If you want, post the ENTIRE error message.
  26. #44
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    4
    Ok i was able to get that message to go away here is the code below.

    Now im getting this error: Error Invoking CFC:C:\Coldfuison9\Project\ArtistSearch.cfc: Datasource myquery couldn't be found.

    I thought that I defined it by writing it in the function. Then I used it as a source for my second query to use. Is this the correct way?


    .cfm
    <html>

    <head>



    <cfform name="albumform">

    <cfgrid name="songgrid"
    format="html"
    bind="CfC:ArtistSearch.getData(page={cfgridpage},
    pageSize={cfgridpagesize},sortCol={cfgridsortcolumn},
    sortDir={cfgridsortdirection})"
    selectMode="browse"
    width=400
    delete="true"
    pageSize=7>
    <cfgridcolumn name="TITLE" header="Name" width=200>
    <cfgridcolumn name="Artist" header="Type" width=200>
    </cfgrid><br />

    <cfinput name="artist">
    </cfform>





    </body>
    </html>

    .cfc
    <cfcomponent name="ArtistSearch" output="false">



    <cffunction name="getdata" access="remote" returntype="string">
    <cfhttp url="http://localhost:8500/interviewtest/music.xml">
    <cfset biggie = xmlparse("#cfhttp.FileContent#")>
    <cfset txe = biggie.album.tracks.song>
    <cfset box = arraylen(txe)>
    <cfset myquery = QueryNew("title, artist")>
    <cfset temp = QueryAddRow(myquery, #box#)>
    <cfloop index="i" from = "1" to = #box#>
    <cfset temp = QuerySetCell (myquery, "title", #biggie.album.tracks.song[i].title.xmltext#, #i#)>
    <cfset temp = QuerySetCell (myquery, "artist", #biggie.album.tracks.song[i].artist.xmltext#, #i#)>
    </cfloop>
    <cfquery name="Search" datasource="myquery">
    select TITLE, ARTIST from SONG
    <cfif isDefined("txe") >
    where artist = '#txe#'
    </cfif>
    </cfquery>

    </cffunction>



    </cfcomponent>
  28. #45
  29. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    Originally Posted by absumter12
    I thought that I defined it by writing it in the function. Then I used it as a source for my second query to use. Is this the correct way?
    No, that is not how you query an existing result set.

IMN logo majestic logo threadwatch logo seochat tools logo