bug 2921 : Frankly this is a solution I take no pride in. Paging is disabled on search. This is OK if search is sufficiently focussed, but a bit untidy when it isn't.

status 2921: resolved FIXED
This commit is contained in:
sb 2009-05-11 15:01:49 +00:00
parent 74e730c444
commit ba7e48348a
2 changed files with 53 additions and 16 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes Transform ADL into (partial) controller classes
$Author: sb $ $Author: sb $
$Revision: 1.40 $ $Revision: 1.41 $
$Date: 2009-05-08 16:27:24 $ $Date: 2009-05-11 15:01:49 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -72,7 +72,7 @@
// //
// Automatically generated abstract super class for controllers for the // Automatically generated abstract super class for controllers for the
// <xsl:value-of select="/adl:application/@name"/> application; generated using // <xsl:value-of select="/adl:application/@name"/> application; generated using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.40 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.41 $', 10)"/>
// //
// <xsl:value-of select="/adl:application/@revision"/> // <xsl:value-of select="/adl:application/@revision"/>
// //
@ -182,7 +182,7 @@
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.40 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.41 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -741,6 +741,7 @@
ICriteria search = ICriteria search =
hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>)); hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>));
Boolean withSearchCriteria = false;
<xsl:for-each select="adl:property"> <xsl:for-each select="adl:property">
<xsl:variable name="base-type"> <xsl:variable name="base-type">
@ -758,8 +759,10 @@
<xsl:with-param name="property" select="."/> <xsl:with-param name="property" select="."/>
<xsl:with-param name="value">Params["<xsl:value-of select="concat( 'search_', @name)"/>"]</xsl:with-param> <xsl:with-param name="value">Params["<xsl:value-of select="concat( 'search_', @name)"/>"]</xsl:with-param>
</xsl:call-template>; </xsl:call-template>;
} PropertyBag["<xsl:value-of select="concat( 'search_', @name)"/>"] = Params[ "<xsl:value-of select="concat( 'search_', @name)"/>"];
</xsl:otherwise> withSearchCriteria = true;
}
</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="adl:property[@distinct='user' or @distinct='all']"> <xsl:for-each select="adl:property[@distinct='user' or @distinct='all']">
@ -768,8 +771,15 @@
IList&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt; instances = search.List&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt;(); IList&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt; instances = search.List&lt;<xsl:value-of select="concat( $entityns, '.', @name)"/>&gt;();
/* bug 2921: suppress pagination when searching, as we can't fold the search params into the pagination */
int showRecords = instances.Count;
if ( ! withSearchCriteria) {
showRecords = <xsl:value-of select="$records-per-page"/>;
}
PropertyBag["instances"] = PropertyBag["instances"] =
PaginationHelper.CreatePagination( this, instances, <xsl:value-of select="$records-per-page"/>); PaginationHelper.CreatePagination( this, instances, showRecords);
RenderViewWithFailover(view + ".vm", view + ".auto.vm"); RenderViewWithFailover(view + ".vm", view + ".auto.vm");
} }

View file

@ -15,8 +15,8 @@
Transform ADL into velocity view templates Transform ADL into velocity view templates
$Author: sb $ $Author: sb $
$Revision: 1.57 $ $Revision: 1.58 $
$Date: 2009-05-07 08:42:01 $ $Date: 2009-05-11 15:01:49 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! --> Whitespace (or lack of it) is significant! -->
@ -1026,11 +1026,22 @@
<xsl:param name="list"/> <xsl:param name="list"/>
<div class="content"> <div class="content">
<div class="controls"> <div class="controls">
<span class="pagination status"> <span class="pagination status">
Showing $instances.FirstItem - $instances.LastItem of $instances.TotalItems Showing $instances.FirstItem - $instances.LastItem of $instances.TotalItems
</span> </span>
#if ( <xsl:for-each select="adl:field">
<xsl:variable name="field" select="."/>
<xsl:variable name="search-name"
select="concat('$search_', ancestor::adl:entity//adl:property[@name=$field/@property]/@name)"/>
<xsl:value-of select="$search-name"/>
<xsl:if test="not( position() = last())">||</xsl:if>
</xsl:for-each> )
<xsl:comment>Suppressing pagination in favour of search</xsl:comment>
#else
<span class="pagination control"> <span class="pagination control">
#if($instances.HasFirst) $PaginationHelper.CreatePageLink( 1, "&lt;&lt;" ) #end #if($instances.HasFirst)
$PaginationHelper.CreatePageLink( 1, "&lt;&lt;" )
#end
#if(!$instances.HasFirst) &lt;&lt; #end #if(!$instances.HasFirst) &lt;&lt; #end
</span> </span>
<span class="pagination control"> <span class="pagination control">
@ -1045,6 +1056,7 @@
#if($instances.HasLast) $PaginationHelper.CreatePageLink( $instances.LastIndex, "&gt;&gt;" ) #end #if($instances.HasLast) $PaginationHelper.CreatePageLink( $instances.LastIndex, "&gt;&gt;" ) #end
#if(!$instances.HasLast) &gt;&gt; #end #if(!$instances.HasLast) &gt;&gt; #end
</span> </span>
#end
<xsl:if test="$list/../adl:form"> <xsl:if test="$list/../adl:form">
<span class="add"> <span class="add">
<a> <a>
@ -1129,8 +1141,9 @@
</xsl:variable> </xsl:variable>
<xsl:if test="$size != 0"> <xsl:if test="$size != 0">
<input> <input>
<xsl:variable name="search-name" select="concat('search_',$entity//adl:property[@name=$field/@property]/@name)"/>
<xsl:attribute name="name"> <xsl:attribute name="name">
<xsl:value-of select="concat('search_',$entity//adl:property[@name=$field/@property]/@name)"/> <xsl:value-of select="$search-name"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="size"> <xsl:attribute name="size">
<xsl:choose> <xsl:choose>
@ -1141,7 +1154,7 @@
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="value"> <xsl:attribute name="value">
<xsl:value-of select="concat( '$!search_', $entity//adl:property[@name=$field/@property]/@name)"/> <xsl:value-of select="concat( '$!', $search-name)"/>
</xsl:attribute> </xsl:attribute>
</input> </input>
</xsl:if> </xsl:if>
@ -1807,7 +1820,7 @@
Auto generated Velocity macro for <xsl:value-of select="@name"/>, Auto generated Velocity macro for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.57 $', 10)"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.58 $', 10)"/>
Generation parameters were: Generation parameters were:
area-name: <xsl:value-of select="$area-name"/> area-name: <xsl:value-of select="$area-name"/>
default-url: <xsl:value-of select="$default-url"/> default-url: <xsl:value-of select="$default-url"/>
@ -1974,6 +1987,20 @@
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<!-- compose the list of search parameters to append to a pagination request; note that this does
not currently work but I have some hopes that in future it will and in the meantime it costs us
little -->
<xsl:template name="pagination-search-params">
<xsl:param name="form" select="."/>
"%{<xsl:for-each select="$form/adl:field">
<xsl:variable name="field" select="."/>
<xsl:variable name="search-name"
select="concat('search_',$form/ancestor::adl:entity//adl:property[@name=$field/@property]/@name)"/>
<xsl:value-of select="concat( $search-name, '=$', $search-name)"/>
<xsl:if test="not( position() = last())">,</xsl:if>
</xsl:for-each>}"
</xsl:template>
<xsl:template match="groups"> <xsl:template match="groups">
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:template> </xsl:template>