Yep--missed the space!

Baz wrote:

Notice that it searches for ' desc' with a preceding space. Column names
can't have spaces so I think it works. There is the 1 case where if your
column is actually called DESC and you pass it into sortByFieldList with a
leading space, it would not realize it was the column name. But that can be
solved with a simple trim in the first cfif like so:

<cfloop list="#arguments.sortByFieldList#" index="x">
   <cfif findnocase(' desc',trim(x))>
&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;

I think this snippet does the trick... Mr.Hughes?

Baz


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark
Mazelin
Sent: Friday, February 10, 2006 9:52 PM
To: [email protected]
Subject: Re: Reactor For CF sortByFieldList now accepts asc/desc

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/





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