I believe your code will break if you have a field that contains "desc" in it. Better to split again on a space to determine sort order. You would need to do something like this (off the top of my head, so it isn't tested):
<cfset order="asc">
<cfif (listlen(x, " ") eq 2)>
   <cfset order=listgetat(x, 2, " ")>
</cfif>
<cfswitch expression="#order#">
<cfcase value="asc">
   <cfset query.getOrder().setAsc(zzz)>
</cfcase>
<cfcase value="desc">
   <cfset query.getOrder().setDesc(zzz)>
</cfcase>
<cfdefaultcase>
   <cfthrow message="You specified an invalid order">
</cfdefaultcase>
</cfswitch>

Mark

Baz wrote:

*I replaced the following code:*

&lt;cfloop list="#arguments.sortByFieldList#" index="x"&gt;

&lt;cfset Query.getOrder().setAsc("<xsl:value-of select="object/@name" />", trim(x)) /&gt;

&lt;/cfloop&gt;

*With this:*

&lt;cfloop list="#arguments.sortByFieldList#" index="x"&gt;

   &lt;cfif findnocase(' desc',x)&gt;

&lt;cfset Query.getOrder().setDesc("<xsl:value-of select="object/@name" />", trim(replacenocase(x,' desc',''))) /&gt;

   &lt;cfelse&gt;

&lt;cfset Query.getOrder().setAsc("<xsl:value-of select="object/@name" />", trim(replacenocase(x,' asc',''))) /&gt;

&lt;/cfif&gt;
&lt;/cfloop&gt;

======================

Depends on what the source looks like.

=======================

I added a couple of lines to /Reactor/xsl/gateway.project.xsl and now my

sortByFieldList processes asc/desc! There doesn't seem to be any drawback to

what I did. Perhaps it works its way into Reactor?

Baz

-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/







-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at 
http://www.mail-archive.com/reactor%40doughughes.net/

Reply via email to