Forum OpenACS Q&A: Using list-builder and order by

Request notifications

Collapse
Posted by Jade Rubick on
I've put up some preliminary notes on using list-builder. I'll update it over time as I become more familiar with it:

http://rubick.com/openacs/list-builder

Here's my question:

I have set up a list builder as follows:

.tcl

    template::list::create \
        -name revisions \
        -multirow revisions \
        -key revision_id \
        -elements {
            revision_id {
                label "Subject"
                display_col task_title
                link_url_col item_url
                link_html { title "View this revision" }
                display_template {<if @revisions.live_revision@ eq @revisions.revision_id@><B>@revisions.task_title@</B></if><else>@revisions.task_title@</else>}
            }
            description {
                label "Description"
            }
            percent_complete {
                label "Status"
                display_template mailto:"@revisions.percent_complete@\%"
            }
            start_date {
                label "Start date"
            }
            end_date {
                label "End date"
            }
        }

    db_multirow -extend { item_url } revisions task_revisions_query {
    } {
        set item_url [export_vars -base "task-one" { revision_id task_id}]
    }

.adp

<listtemplate name="revisions"></listtemplate>

.xql

  <fullquery name="task_revisions_query">
    <querytext>
    SELECT
        t.item_id,
        t.revision_id,
        i.live_revision,
        t.title as task_title,
        t.description,
    to_char(t.start_date,'MM/DD/YYYY') as start_date,
    to_char(t.end_date,'MM/DD/YYYY') as end_date,
        t.percent_complete
    FROM
    pm_tasks_revisionsx t, cr_items i
    WHERE
        t.item_id = :task_id and
        t.item_id = i.item_id
        ORDER BY
        t.revision_id desc
    </querytext>
  </fullquery>

-------------------------
This works quite well. However, I'm having difficulty figuring out how to set up order by statements. The docs don't really seem to go into this much. Could anyone help out here? I imagine I need to put something in the .xql file, and add in the -orderby clause.

Also, is there a way to make the table created by list-builder to be width=100%?

Collapse
Posted by Dave Bauer on
All I did was use template::list::orderby_clause -name list-name to get the order by clause and added $orderby_clause to the query in the xql file.

You have to prepend "order by" to whatever the proc returns.

To set the width you can use CSS. I actually created a new CSS class with width=100% attribute and edited the list template file.

The may be a better way to do that.

Collapse
Posted by Dave Bauer on
Oops,

I left out part of it.

In template::list::create you need to pass in the spec for which elements can be ordered.

-orderby {
   element_name {orderby column_name}
}

You can optionall specify addition attributes for the orderby including the default direction. The full doc of what you can specify is in the api-doc for template::list::orderby_create.

Collapse
Posted by Jade Rubick on
Thank you Dave. I got it working. Here's how:

.tcl

ad_page_contract {
...

} {
    task_revision_id:integer,optional
    orderby:optional
} -properties {

...
}
...

template::list::create \
    -name revisions \
    -multirow revisions \
    -key revision_id \
    -elements {
        revision_id {
            label "Subject"
            display_col task_title
            link_url_col item_url
            link_html { title "View this revision" }
            display_template {<if @revisions.live_revision@ eq @revisions.revision_id@><B>@revisions.task_title@</B></if><else>@revisions.task_title@</else>}
        }
        description {
            label "Description"
        }
        percent_complete {
            label "Status"
            display_template "@revisions.percent_complete@\%"
        }
        start_date {
            label "Start date"
        }
        end_date {
            label "End date"
        }
    } \
    -orderby {
        revision_id {orderby revision_id}
        percent_complete {orderby percent_complete}
        start_date {orderby start_date}
        end_date {orderby end_date}
    } \
    -filters {
        task_revision_id
    }

if {[exists_and_not_null orderby]} {
    set orderby_clause "ORDER BY [template::list::orderby_clause -name revisions]"
} else {
    set orderby_clause "ORDER BY revision_id desc"
}

db_multirow -extend { item_url } revisions task_revisions_query {
} {
    set item_url [export_vars -base "task-one" -override {{task_revision_id $revision_id}} -exclude {revision_id} { revision_id task_id}]
}
.xql
  <fullquery name="task_revisions_query">
    <querytext>
	SELECT
        t.item_id,
        t.revision_id,
        i.live_revision,
        t.title as task_title,
        t.description,
	to_char(t.start_date,'MM/DD/YYYY') as start_date,
	to_char(t.end_date,'MM/DD/YYYY') as end_date,
        t.percent_complete
	FROM
	pm_tasks_revisionsx t, cr_items i
	WHERE
        t.item_id = :task_id and
        t.item_id = i.item_id
        $orderby_clause
    </querytext>
  </fullquery>
The .adp file is the same as before.

Note the use of the filters section to make the task_revision_id be passed in when you click on the sorting links.

Collapse
Posted by Lars Pind on
Glad to see that you guys are using the list builder.

A few minor comments:

1) You can get template::list::orderby_clause to spit out the 'order by' part as well by adding the switch -orderby. I just realized that this switch wasn't documented so I added the documentation.

2) I usually specify the call to orderby_clause directly in the query in the .xql file:

select ...
from  ...
where  ...
[template::list::orderby_clause -name listname -orderby]

3) Your -filters trick to add task_revision_id is unfortunalyte the only way to get the list builder to export variables right now. However, for good measure, you should add an empty list afterwards, like this:

-filters {
    task_revision_id {}
}

The reason is that filters normally have specificaion blocks, just like any other element. It doesn't make any difference in this situation, but if you were to add another filter later, you could run into trouble, because the 'name' and 'specification' blocks could be confused.

-filters {
  task_revision_id
  some_other_filter {
      label "This will not do what you want it to"
  }
}

4) If you add a 'default_value refvision_id' to your orderby section, you won't have to do if exists_and_not_null orderby part:

-orderby {
        revision_id {orderby revision_id}
        percent_complete {orderby percent_complete}
        start_date {orderby start_date}
        end_date {orderby end_date}
        default_value revision_id
    } \

5) And then to answer your question to me in private email: No, there's currently no way to change the name of the query parameter used for orderby currently named 'orderby'. Which means you cannot have multiple sorted lists on the same page. I'll look into fixing this.

/Lars

Collapse
Posted by Lars Pind on
6) Added -html switch to template::list::create. To set width=100% on your table, say

-html { width 100% }

(this is on tip of oacs-4-6 branch)

/Lars

Collapse
Posted by Lars Pind on
7) CSVs:

say

template::list::create \
    ... \
    -selected_format csv \
    -formats {
        ...
        csv { output csv }
    }

Then around the end of the .tcl file, say

template::list::write_output -name listname

/Lars

Collapse
Posted by Lars Pind on
Re 4) above: You need to say 'default_value revision_id,asc' (with comma direction) in order for it to work.

Re 5) above: I've added an -orderby_name switch to let you set the name of the orderby filter.

However, the same problem applies to 'groupby' and 'page' (for pagination). I haven't fixed those. Also, if you have filters with the same name in two lists, you're also in trouble.

I think the right solution would be to let you prepend the list name to all your query variables, so as to completely separate the namespaces of multiple lists on the same page. That'll take a little longer to do, though. (Funding will be accepted :))

/Lars

Collapse
Posted by Timo Hentschel on
Ok. I haven't used the listbuilder yet, but only had a look at the examples posted here. I have to say I am not really thrilled so see adp-code written in tcl-code. Is there really no other way to do this??? I feel like we're getting back to where ACS3 has been and I certainly feel I don't want to go there again. Is there no other way to do it? Can't we do these kind of switches inside the adp where it really belongs? Maybe we could add some adp-tag to be used inside the listtemplate-tag to deal with the cases where we need particular adp-code.
Collapse
Posted by Lars Pind on
Timo,

I assume you're talking about the 'display_template' part.

This is a result of the way that list builder came about. I started development because I thought we had a client, but then it turned out that we did not. So there are features that didn't get implemented yet, and one of them is the ability to set these kinds of things in the ADP file. Check out the spec (the implementation ended up quite different, but the ideas are there):

http://www.collaboraid.biz/developer/list-builder-spec

I don't think that it's terribly bad in this particular situation. It's only one parameter, and you put in something which is explicitly ADP, and which is directly copied into the resulting page template by the rendering procedure.

What ACS 3 did was mix Tcl code with HTML code arbitrarily. This is very controlled, in contrast.

So patience, dear friend. As soon as we can find the money or excuse to fix it, we will :)

/Lars

Collapse
Posted by Timo Hentschel on
Lars, that is really good to know. I can totally relate to start developing things, but halfway through things happen that requires to redirect your focus to other things.

But in the end, we should not get overly used to the default_template part and hope that funding or an excuse for fixing arises soon so that people will not have to dig through too much code once this part is done as you intended to - placing adp where adp belongs.

I sincerely hope that this issue will not be forgotten since I really dislike the idea of mixing tcl and html again (and adp is output-html in the end), although I have to agree that ACS3 had way worse code than this, but still....

Greetings to Kopenhagen from India,
Timo

Collapse
Posted by Jon Griffin on
Lars,
Should we merge our two procs? Mine does a lot of things yours doesn't and vice versa. I don't think that we need 2 (actually 3 if you count ad_table/paginate) versions of the same thing.
Collapse
Posted by Jade Rubick on
Wow, Lars, thanks for all the help.

Now I have three list-builders going in one page.

I've linked in this thread from my LB page.

Collapse
Posted by Lars Pind on
Jon,

Absolutely. What do you have?

I saw your post about a new paginator, which I appreciate, since the old one with which I integrated list builder truly sucks.

Alas, I haven't had time to do so yet.

Apart from that, what is there to look at, and what does yours do that mine doesn't?

/Lars

Collapse
Posted by Jun Yamog on
Dave introduced me to the list builder, I think its great.  Although I hope that it won't turn out to be too specific and less flexible when it finishes.

An example of the direction that maybe a problem is.  I wan't my check box on the right side.  I think this can't be done on the adp/template of the list.  I haven't use the paginator of the list builder, but it would be nice if.  The future direction is that the paginator is not too coupled with the list builder.  Its also a bit hard to customize your template, you need to use noparse, or some other trick.  Read the list-procs.tcl code.  Its not something a designer level developer may always have.

All in all, I think the list builder is helpful to me.  Just giving some feedback on it and hopefully it will get better.

Collapse
Posted by Jon Griffin on
My paginator/table is not coupled to the html, it also allows sorting of the complete result set which the original doesn't (it only sorts the cached result set).
Also, mine was written without the need for caching and allows bindvars and many other features from the old procs rewritten to be not only faster but more flexible.
You can have multiple paginators on one page, and dynamically choose the size of the result set, so a user can see 100 records instead of 10 etc.
Brad Duell just updated some things so I will post a new revision with some new features today.
Collapse
Posted by Robert Locke on
Hi all,

I've just started using Lars' cool list-builder and have a few questions/comments:

* Since my installation is based on oacs-4-6-3-final, I copied over list-procs.tcl, pagination-procs.tcl, and acs-templating/resources/lists/* from the tip of oacs-4-6.  Things seem to be working, but would you happen to know if that would break anything?

* In order to get pagination to work, I specified the page_size and page_query parameters.  I then had to call get_reference to get the name of the paginator object.  I then called paginator::get_data to create the final multirow.  Here's the code:

ad_page_contract {
} {
    {page:naturalnum 1}
}

list::create -name users \
        -multirow users \
        -key user_id \
        -elements {user_id    {label "User ID"}
                  email      {label "Email"}
                  full_name  {label "Name"}
                  registered {label "Registered"}
        } \
        -page_size 5 \
        -page_query {
            select user_id from cc_users
        }

list::get_reference -name users

paginator get_data fetch_users $list_properties(paginator_name) users {
        select
            user_id,
            email,
            first_names || ' ' || last_name as full_name,
            to_char(creation_date, 'MM/DD/YYYY HH:MI AM') as registered,
            to_char(last_visit, 'MM/DD/YYYY HH:MI AM') as last_visit
        from
            cc_users where user_id in (CURRENT_PAGE_SET)
    } user_id $page

* Is that the proper way to do pagination?  What about pagination context?

* Will try to figure out "filters" now.  But, while I have your attention, I would appreciate a primer on the purpose of filters and how they work.  Perhaps an example? =)

Thanks for contributing this Lars.  I think it's wonderful that we now have a standard and powerful way for creating tables/lists.

Collapse
Posted by Andrei Popov on
I've doen the same thing and in my case I (sometimes) need to do a reload of a page to get it right -- first time around I (sometimes) get an error, but after a reload it is all fine.  Weird.
Collapse
Posted by Lars Pind on
Nope. You don't need to talk to the paginator yourself at all.

Create the list the way you do, then include the following in your query:

select ...
from  ...
where  ...
and    activity_id in ([template::list::page_get_ids -name $list_name])

That should do it.

Pagination is still kindof sketchy. The "old" paginator which I'm using is complicated and does this pagination in Tcl instead of in the database, etc.

Whenever I get a chance, I want to try and integrate with Jon Griffin's new paginator, which should be simpler.

/Lars

Collapse
Posted by Robert Locke on
Andrei: I'm not seeing the behavior you're describing, but I will look out for it.

Lars: your method is much cleaner, thanks!  Is there any documentation on filters?

Thanks again...

Collapse
Posted by Lars Pind on
Have you looked at documentation for template::list::filter::create?
Collapse
Posted by Robert Locke on
Hi Lars,

Yes, briefly.  Sorry, I should've been clearer.  I guess I was hoping for an example or two of using it in practice.  The docs are great, but an example makes things extra clear.  Witness mine and Andrei's "incorrect" usage of the paginator.

No worries though, I'm sure it's easy to figure out.  I will work on it when I get the chance and post an example for other's benefit.

Thanks!

Collapse
Posted by Lars Pind on
Collapse
Posted by Robert Locke on
Ask and ye shall receive!  Thanks Lars...
Collapse
Posted by Jon Griffin on
Lars,
Your link above is broken.
Collapse
Posted by Lars Pind on
Yes, but the code is now in stock logger in HEAD. packages/logger/www/index.tcl
Collapse
Posted by Jade Rubick on
Collapse
28: Pagination (response to 27)
Posted by Joel Aufrecht on
I'm a little lost.  If I understand correctly, Robert Locke's post (Aug 19 2003 07:13:55, Re: Using list-builder and pagination) is talking about how to use the old paginator, which retrieves a full data set and then does pagination in tcl.  I can't find anything that I'm sure refers to using Jon Griffin's paginator functions within list-builder - Jon's functions build an html result.  How do I use Jon's pagination within listbuilder?
Collapse
Posted by Jon Griffin on
Joel,
The paginator doesn't have to return HTML, see the switches.

Also, while I think the list builder is cool, it is way to complex for most uses and as you see you have to specify different code just to paginate.

I wrote, and Brad Duell has been adding to, my paginator to combine both funtions and it is much faster.

A. All sorts are done in the DB where it should be, no more tcl madness to sort.
B. It uses the almost the same syntax as the old ad_ procs.
C. It has been extended by Brad to do much more.
D. It is already integrated with external dhtml widgets.
E. It is in production on several sites, some with very large querys that took minutes with the old paginator and under a second with the new.

I am looking into integrating my stuff with list-builder, but with so much dependency on templating procs it will be difficult to do. I feel that unfortunatly list-builder is becoming the de-facto UI widget, but I will update my code base with Brad's latest changes tomorrow.

Collapse
Posted by Joel Aufrecht on
"The paginator doesn't have to return HTML, see the switches."  I understand this in theory; in practice I stared at the screen for ten or twenty minutes and didn't really grok much (and couldn't get the example to work readily).  I was hoping someone else already had a good working example of "new" paginator with list-builder.
Collapse
Posted by Malte Sussdorff on
After going through all the documentation I still could not find what I was looking for to get listbuilder to work for me with sorting, pagination and filters. Therefore I wrote a quick document which you can take a look at.
Collapse
Posted by Richard Hamilton on
I think that it is worth noting on this thread that Don has done a lot of recent work (late 2004) on the paginator that is integrated into list-builder to address the performance issues whilst retaining the caching capabilities.

Here are his three most relevant posts:
____________________________________________________________
1)
Richard ... while openacs.org was down for upgrade this weekend I worked on pagination for the forums package, using list builder, and now understand it thoroughly.

I also understand how to make it paginate very quickly, and think I can hack it up to do so without having to modify any of the client code.

I think this will make use of Jon's pagination code unnecessary, i.e. we'll want to recommend use of list builder and deprecate use of the existing paginator.

The reason it's so slow now is that it uses the paginator but inefficiently. Rather than go into endless details I think I'll just fix it.

I would actually like to investigate writing a version of list builder that combines the multirow functionality afterwards. The current mechanism - call a list builder proc which then sets global structures for magic tcl procs you call embedded in .xql files to modify your query in ways that fit the needs of the listtemplate tag - seems like a gawdawful kludge to me. By combining the functionality it could, among other things, do reasonably efficient pagination using the display query itself wrapped appropriately in LIMIT/OFFSET rather than require a separate prepare-for-pagination query as is necessary now.
____________________________________________________________
Then later:

2)
The paginator, which listbuilder is using, requires you to first fill a cache of row ids for the entire data structure being displayed. You then query display information using specific row ids from that cache.

Filling the cache is very slow if you have a large datastructure, for instance 5,600 threads in a forum like we do in the openacs Q&A forum. The query itself's not too bad, it's pulling the rows out of the rowset and stuffing them into an nsv cache variable that's taking most of the time.

The design philosphy behind the paginator seems to be "pay a fairly steep up-front cost so accessing every page afterwards costs roughly the same".

This isn't good. Normally people are going to reference more recent threads, blog entries, bugs sorted by some criteria, etc. LIMIT/OFFSET and Oracle ROWNUM tricks are faster for early entries in the rowset than those at the end, but that's OK given common usage patterns. Besides both Oracle and PG implement these constructs quite well, we don't really care if accessing the very first thread in the openacs Q&A forum takes a couple of tenths of a second longer than accessing the most recent one.

To put it bluntly the paginator's a bit evil and I'll just rewrite list builder to not use it, except perhaps the bits that generate that nice navigation bar.
____________________________________________________________

and finally:

3)
I've commited my improvements to the list builder's pagination code. Essentially I've sped it up by creating a separate paginator instance for each PAGE GROUP rather than one for the ENTIRE LIST. This means that on openacs.org's Q&A forum, rather than filling a cache of 5500 entries whenever the cache is flushed, we're only filling 330, using LIMIT+OFFSET/ROWNUM tricks. We then get the benefit of having cached the keys for the current page group until there's another post in the case of forums (not all clients of the list builder enable caching, of course). I've also gotten rid of the Tcl-based sorting of the keys returned for use in the page display query's IN (keys) clause, a minor speedup. There's probably still a lot of room for improvement, i.e. I can make lighter-weight list builder specific code to execute and cache the pagination query, etc. I'll poke at it periodically. Currently the OpenACS Q&A forum takes about 1.6 seconds to display if the cache is flushed. It took about 18 seconds using the existing list builder. When the cache is available it takes about 750 milliseconds. Much of that seems to be running the listtemplate tag as the shorter the number of rows, the faster it goes. Notice that performance of this can be impacted by changing the number of rows per page, and page groups per navigation widget, so I'll probably add these as parameters to forums at some point. You get quicker page displays by shrinking those numbers. And of course I haven't added the performance improvements to forums itself that I have in mind ... those will help, too.
____________________________________________________________

So the current position is that List Builder pagination now works acceptably and is scaleable. However Don can think of ways to further improve things.

Collapse
Posted by Don Baccus on
I think the greatly enhanced performance of the forums on openacs.org itself is proof of the increase in performance of the list builder when pagination is used.

It's not the entire increase, we also started recording thread-count information rather than use count(*) queries, a couple of slow queries were found and improved by people other than myself, etc.

But the list builder itself now scales quite nicely if you use pagination, and even more nicely if you enable caching (which requires some simple logic to figure out when to flush the cache).

Collapse
Posted by Vincent Gulinao on
Thanks for the doc!

I got everything work in my list-builder, except for pagination. I followed as carefully as I can the instructions. I even tried restarting OACS, but still no luck.

<snip from error page>
can't read "properties(row_ids)": no such element in array
    while executing
"lrange $properties(row_ids) $start $end"
    (procedure "get_row_ids" line 9)
    invoked from within
"get_row_ids $name $page"
    (procedure "paginator::get_query" line 2)
    invoked from within
"paginator::get_query push_sched push_sched_id 1"
    ("eval" body line 1)
    invoked from within
"eval paginator::$command $args"
    (procedure "template::paginator" line 2)
    invoked from within
"template::paginator get_query $list_properties(paginator_name) $list_properties(key) $list_properties(filter,page)"
    (procedure "page_get_ids" line 13)
    invoked from within
"page_get_ids -name $name"
    (procedure "template::list::page_where_clause" line 20)
    invoked from within
"template::list::page_where_clause -and -name "push_sched""
    invoked from within
</snip>

Any hints?

Collapse
Posted by Lear Zumaeta on
Hi, I want to know if is possible change te format of the elemnt that shown on the array, sorry for my english, I have this as shown on the tradicional pagination list

< 1 2 3 4 5 6 7 8 9 10 > >>

Gaceta norma numero año autoridad
---------------------------------------------------------
375 49 25 1906 8
753 49 12 1909 8

the tipe for 49=Ley and 8=asamblea

but I want list like this

Ley 25 1906
375
asamblea

ley 12 1909
753
asamblea

and go on

is this possible or I have to limited for the tradicional pagination list

Collapse
Posted by Brian Fenton on
Hi Lear,

I'm not sure if this will do what you want, but you could take a look at using "group by" with list builder. See here for an example: http://openacs.org/blog/one-entry?entry_id=907364

hope this helps
Brian Fenton

Collapse
Posted by Lear Zumaeta on
Hello Brian I have this in my .tcl

###########################################################
request create -params {
sql1 -datatype text -optional
}

ad_page_contract {
} {
    {page:naturalnum 1}
}

list::create -name users \
        -multirow users \
        -key num_sec \
        -page_size 10 \
        -page_query { select num_sec from procadm.t_normas where $sql1} \
        -elements {
                  num_sec {
                        display_template {<table width="800" border="0"><tr><td width="2%" valign="top" align="center"><font face="Arial, Helvetica, sans-serif" color="#FF0000" size="3"><b><img src="puntero.gif" width="17" height="17"></b></font></td><td width="96%" valign="top" bgcolor="#E8E8E8" align="justify">@users.desc_norma@&nbsp;@users.num_norma@&nbsp;de&nbsp;@users.anio_gac@<br>Número de Gaceta:&nbsp;@users.num_gaeta@<br>Autoridad:&nbsp;@users.desc_autoridad@<br>Título:&nbsp;@users.titulo@</td></tr></table> }
            }
        }

  set query  "select a.num_sec num_sec, num_gaceta,to_char(fecha_gaceta,'yyyy') anio_gac, a.norma, desc_norma, num_norma, titulo, cod_autoridad,desc_autoridad \
from procadm.t_normas a, procadm.t_tipo_norma b,procadm.t_autoridad c where $sql1 and \
a.norma=b.num_sec and \
a.cod_autoridad=c.num_sec and \
a.num_sec in ([template::list::page_get_ids -name users])"

    db_multirow users users_query $query

#########################################################

I past the value sql1 from another script and list the first  10 rows fine when I put the value from keyboard but when I clik the next 10 rows I feel like sql1 lost the value in the array and list me an error.

What I am doing wrong.  Please sorry about my english

Collapse
Posted by Brian Fenton on
Hi Lear,

I don't think it's a good idea to be passing in your SQL query as a parameter to the page - you're leaving yourself open to potential SQL Injection attacks.

Also I don't think you need the "request create" - just use ad_page_contract to handle any form variables.

Brian

How I do that? Do you have any documentation or example script on this matter. I have this script with elements form that a I enter by keyboard but when I excecute the submit instruccion, runs the select query on the list array for the first page but when I past to the next page=2 I lost the information...
Sure, there are loads of examples in the OpenACS codebase. Try this one for starters: http://cvs.openacs.org/cvs/*checkout*/openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl?rev=1.2
I don't think it's a good idea to be passing in your SQL query as a parameter to the page - you're leaving yourself open to potential SQL Injection attacks.

Also I don't think you need the "request create" - just use ad_page_contract to handle any form variables.

How I use ad_page_contract to do this, handle any form variables from another script passed

How I use ad_page_contract to do this, handle any form variables from another script passed
Hi Brian, forgiveness for asking to much I´m trying to understand those templating demos but I barracks,

this is a portion of the script that pass parameters
index_lista.tcl

if {  [string equal $keyword {}] } {

  if {  ! [ string compare $sql1 "no"] } {

        set display "doc_list"
        set band4 "12"
        element set_error func_search error2_search " Por favor introduzca su busqueda"
        return
        } else {
# past of parameter to prueba_list_builder?
template::forward prueba_list_builder?sql1=$sql1
}

This is the code for the prueba_list_builder

ad_page_contract {
} {
            {page:optional}
}

request create -params {
  sql1 -datatype text -optional
}

if { ! [request is_valid] } { return }

set sql1 $sql1

list::create -name users \
        -multirow users \
        -key num_sec \
        -pass_properties { sql1 } \
        -page_size 10 \
        -page_query { select num_sec from procadm.t_normas where $sql1} \
        -elements {
                  num_sec {
                        display_template {<table width="800" border="0" cellspacing="6" cellpadding="6"><tr><td width="2%" valign="top" align="center"><font face="Arial, Helvetica, sans-serif" color="#FF0000" size="3"><b><img src="puntero.gif" width="17" height="17"></b></font></td><td width="96%" valign="top" align="justify">@sql1@<br>@users.desc_norma@&nbsp;@users.num_norma@&nbsp;de&nbsp;@users.anio_gac@<br>Número de Gaeta:&nbsp;@users.num_gaceta@<br>Autoridad:&nbsp;@users.desc_autoridad@<br>Título:&nbsp;@users.titulo@</td></tr></table> }
            }
        }

  set query  "select a.num_sec num_sec, num_gaceta,to_char(fecha_gaceta,'yyyy') anio_gac, a.norma, desc_norma, num_norma, titulo, cod_autoridad,
desc_autoridad \
from procadm.t_normas a, procadm.t_tipo_norma b,procadm.t_autoridad c where $sql1 and \
a.norma=b.num_sec and
a.cod_autoridad=c.num_sec and
a.num_sec in ([template::list::page_get_ids -name users])"

db_multirow users users_query $query

the view showme the value of variable for the first page but when I past to the second the variable lost the value

Collapse
Posted by Lear Zumaeta on
Hi Lars, forgiveness for asking to much,

this is a portion of the script that I want to pass parameters
index_lista.tcl

if {  [string equal $keyword {}] } {

  if {  ! [ string compare $sql1 "no"] } {

        set display "doc_list"
        set band4 "12"
        element set_error func_search error2_search " Por favor introduzca su busqueda"
        return
        } else {
# past of parameter to prueba_list_builder?
template::forward prueba_list_builder?sql1=$sql1
}

#This is the code for the prueba_list_builder

ad_page_contract {
} {
            {page:optional}
}

request create -params {
  sql1 -datatype text -optional
}

if { ! [request is_valid] } { return }

set sql1 $sql1

list::create -name users \
        -multirow users \
        -key num_sec \
        -pass_properties { sql1 } \
        -page_size 10 \
        -page_query { select num_sec from procadm.t_normas where $sql1} \
        -elements {
                  num_sec {
                        display_template {<table width="800" border="0" cellspacing="6" cellpadding="6"><tr><td width="2%" valign="top" align="center"><font face="Arial, Helvetica, sans-serif" color="#FF0000" size="3"><b><img src="puntero.gif" width="17" height="17"></b></font></td><td width="96%" valign="top" align="justify">@sql1@<br>@users.desc_norma@&nbsp;@users.num_norma@&nbsp;de&nbsp;@users.anio_gac@<br>Número de Gaeta:&nbsp;@users.num_gaceta@<br>Autoridad:&nbsp;@users.desc_autoridad@<br>Título:&nbsp;@users.titulo@</td></tr></table> }
            }
        }

  set query  "select a.num_sec num_sec, num_gaceta,to_char(fecha_gaceta,'yyyy') anio_gac, a.norma, desc_norma, num_norma, titulo, cod_autoridad,
desc_autoridad \
from procadm.t_normas a, procadm.t_tipo_norma b,procadm.t_autoridad c where $sql1 and \
a.norma=b.num_sec and
a.cod_autoridad=c.num_sec and
a.num_sec in ([template::list::page_get_ids -name users])"

db_multirow users users_query $query

the view showme the value of variable for the first page but when I past to the second the variable lost the value