Vadim Gritsenko wrote:
Ok, here is simple one. Forms wizard for editing any XML/bean containing repeating information, with back/forward navigation, and navigation bar to jump to any previous page. For a concrete example of the usecase, let's look at editing family information, and information about each member. First page, "family", will have repeater which you can populate with names of family members. After filling out first page, let's go through each member and show "member" page. This can look like:
<snip/>

What I do in these cases (not for forms but for paged displays) is more or less like the following:

var page = 0;
var numPages = ...; // Total number of pages
while (true) {
        cocoon.sendPageAndWait("uri", { "bizData" : beans[page] });
        page = newPage(page, numPages, cocoon.request.cmd);
}

The page being shown will have navigation buttons with links like "kont(${continuation.id})?cmd=first" (or cmd=next, prev, last). The "newPage" function computes the new page number as follows:

function newPage(page, numPages, cmd) {
        if (cmd == "first") {
                page = 1;
        }
        else if (cmd == "prev" && page > 1) {
                --page;
        }
        else if (cmd == "next" && page < numPages) {
                ++page;
        }
        else if (cmd == "last") {
                page = numPages;
        }
        return page;
}

I don't think it should be difficult to adapt this to forms.

HTH,

Ugo



Reply via email to