dev@jsftemplating.java.net

Re: JSFTemplating: table sorting problem with dynamicTable

From: Karam Singh Badesha <Karam.Badesha_at_Sun.COM>
Date: Wed, 23 Jan 2008 09:28:39 -0800

Attached are the files.

In TableHandlers.java you can look for "fetchNewUsageSummaryTableData"
method.

thanks
Karam

Ken Paulsen wrote:
>
> Hi Karam,
>
> I think it would help me to see more context. Can you provide the
> complete .jsf source and the full handler methods?
>
> Thanks!
>
> Ken
>
> Karam Singh Badesha wrote:
>> Hi Ken,
>> I am having sorting problems with the dynamic table. Here is my jsf
>> code:
>>
>> <sun:dynamicColumnRowGroup
>> id="rowGroup1"
>> data={"$attribute{usageSummaryDataList}"}
>> sourceVar="tRow"
>> styleClasses="rowColor1,rowColor2"
>> columnSort="$attribute{columnSorts}"
>> columnAlign="$attribute{columnAligns}"
>> columnHeaderText="$attribute{columnHeaders}"
>> columnFooterText="$attribute{columnHeaders}"
>> columnSpacerColumn="$attribute{columnSpacers}"
>> columnWidth="$attribute{columnWidths}"
>> columnValue="$attribute{columnValues}"
>> rows="#{pageSession.tableRows}"
>> >
>> </sun:dynamicColumnRowGroup>
>>
>> And here is the code snippet from the handler:
>>
>> for (int i = 1; i <= count; i++) {
>> String temp = "#{tRow.value.col" + i + "}";
>> String temp2 = "col" + i;
>> columnValues.add(temp);
>> columnSorts.add(temp2);
>> columnSpacers.add("#{false}");
>> columnWidths.add(" ");
>> if (i != 1) {
>> columnAligns.add("right");
>> }
>> }
>>
>> This is exactly the same code if I would hardcode the tableColumn on
>> the jsf page (in terms of specifying sort and staticText value). With
>> the above code no matter what column I click on to sort, it always
>> sorts the entries in the first column. Please let me know if I am
>> doing something wrong or if there is a bug in the dynamic table code.
>>
>> thanks
>> Karam



#include "resourceBundle.inc"
<sun:page id="page1" >
<!beforeCreate
    getReleases(lavaReleases=>$pageSession{lavaReleasesList} lavaReleasesSel=>$pageSession{lavaPS});
    convertRequestToPS(requestIn="$requestParameter{lava}" pageSessionIn="#{pageSession.lavaPS}" pageSessionOut=>$pageSession{lava});
    getBuilds(lavaVersion="#{pageSession.lava}" flag="MB ShowAll" lavaBuilds=>$pageSession{lavaBuildsList} lavaBuildsSel=>$pageSession{buildPS});
    convertRequestToPS(requestIn="$requestParameter{build}" pageSessionIn="#{pageSession.buildPS}" pageSessionOut=>$pageSession{build});
    getTools(lavaVersion="#{pageSession.lava}" buildVersion="#{pageSession.build}" lavaProject="All" flag="ShowAll" lavaTools=>$pageSession{lavaToolsList} lavaToolsSel=>$pageSession{toolPS});
    convertRequestToPS(requestIn="$requestParameter{tool}" pageSessionIn="#{pageSession.toolPS}" pageSessionOut=>$pageSession{tool});
    getConfig(tableRows=>$pageSession{tableRows} defaultVersion=>$pageSession{defaultVersion} db=>$pageSession{db} defaultProject=>$pageSession{defaultProject});
    getNewUsageSummaryTableData(lavaVersion="#{pageSession.lava}" buildVersion="#{pageSession.build}" toolName="#{pageSession.tool}" usageSummaryTableData=>$attribute{usageSummaryDataList} columnHeaders=>$attribute{columnHeaders} columnValues=>$attribute{columnValues} columnSorts=>$attribute{columnSorts} columnWidths=>$attribute{columnWidths} columnSpacers=>$attribute{columnSpacers} columnAligns=>$attribute{columnAligns});
/>
#include "commonHeader.inc"
#include "usageReportTab.inc"
"<table cellpadding="0" cellspacing="12" width="100%">
    "<tr><td>
            <sun:label
                id="lavaReleaseMenuLabel"
                for="lavaReleaseMenu"
                style="padding-right:5px;"
                text="#{msgs.chooseLavaRelease}"
            />
            
            <sun:dropDown
                id="lavaReleaseMenu"
                toolTip="#{msgs.chooseLavaRelease}"
                items="#{pageSession.lavaReleasesList}"
                selected="#{pageSession.lava}"
                onChange="DynaFaces.fireAjaxTransaction(
                this,
                {
                execute: this.id + ',form:lavaReleaseMenu,form:submit1button',
                immediate: false,
                inputs: this.id + ',form:lavaReleaseMenu_field,form:submit1button',
                render: 'form:ajaxBuild'
                });"
            />
            <sun:button
                text="Submit AJAX Request"
                id="submit1button"
                visible="#{false}"
                onClick="DynaFaces.fireAjaxTransaction(
                this,
                {
                execute: this.id + ',form:lavaReleaseMenu',
                immediate: false,
                inputs: this.id + ',form:lavaReleaseMenu_field',
                render: 'form:ajaxBuild'
                });
                return false;"
>
                <!command
                getBuilds(lavaVersion="#{pageSession.lava}" flag="MB ShowAll" lavaBuilds=>$pageSession{lavaBuildsList} lavaBuildsSel=>$pageSession{build});
                getTools(lavaVersion="#{pageSession.lava}" buildVersion="#{pageSession.build}" lavaProject="All" flag="ShowAll" lavaTools=>$pageSession{lavaToolsList} lavaToolsSel=>$pageSession{tool});
                />
            </sun:button>
            
            <sun:label
                id="buildMenuLabel"
                for="buildMenu"
                style="padding-right:5px; padding-left:15px;"
                text="#{msgs.chooseBuild}"
            />
            <sun:markup tag="span" id="ajaxBuild">
                <sun:dropDown
                    id="buildMenu"
                    toolTip="#{msgs.chooseBuild}"
                    items="#{pageSession.lavaBuildsList}"
                    selected="#{pageSession.build}"
                    onChange="DynaFaces.fireAjaxTransaction(
                    this,
                    {
                    execute: this.id + ',form:buildMenu,form:submit2button',
                    immediate: false,
                    inputs: this.id + ',form:buildMenu_field,form:submit2button',
                    render: 'form:ajaxTool'
                    });"
                />
                <sun:button
                    text="Submit AJAX Request"
                    id="submit2button"
                    visible="#{false}"
                    onClick="DynaFaces.fireAjaxTransaction(
                    this,
                    {
                    execute: this.id + ',form:buildMenu',
                    immediate: false,
                    inputs: this.id + ',form:buildMenu_field',
                    render: 'form:ajaxTool'
                    });
                    return false;"
>
                    <!command
                    getTools(lavaVersion="#{pageSession.lava}" buildVersion="#{pageSession.build}" lavaProject="All" flag="ShowAll" lavaTools=>$pageSession{lavaToolsList} lavaToolsSel=>$pageSession{tool});
                    />
                </sun:button>
                <sun:label
                    id="toolMenuLabel"
                    for="toolMenu"
                    style="padding-right:5px;padding-left:15px;"
                    text="#{msgs.chooseTool}"
                />
                <sun:markup tag="span" id="ajaxTool">
                    <sun:dropDown
                        id="toolMenu"
                        toolTip="#{msgs.chooseTool}"
                        items="#{pageSession.lavaToolsList}"
                        selected="#{pageSession.tool}"
                    />
                </sun:markup>
            </sun:markup>
            "&nbsp;&nbsp;&nbsp;
            <sun:button
                id="generateButton"
                text="#{msgs.button_generateText}"
                toolTip="#{msgs.button_generateText}"
                onClick="javascript: return submitAndDisable(this, '#{msgs.button_processing}');"
>
                <!command
                redirect(page="usageReport.jsf?lava=#{pageSession.lava}&build=#{pageSession.build}&tool=#{pageSession.tool}");
                />
            </sun:button>
    "</td></tr>
"</table>
"<table cellpadding="0" cellspacing="12" width="100%">
    "<tr><td>
            <sun:staticText text="<b>Usage Summary Report for </b>" />
            <sun:staticText text="<b>#{msgs.chooseLavaRelease} </b>" />
            <sun:staticText text=" #{pageSession.lava} " />
            <sun:staticText text="<b>&nbsp;&nbsp;&nbsp; #{msgs.chooseBuild} </b>" />
            <sun:staticText text=" #{pageSession.build} " />
            <sun:staticText text="<b>&nbsp;&nbsp;&nbsp; #{msgs.chooseTool} </b>" />
            <sun:staticText text=" #{pageSession.tool} " />
    "</td></tr>
    "<tr><td>
            <!-- Sortable Table -->
            <sun:table
                id="table1"
                clearSortButton="#{true}"
                sortPanelToggleButton="#{true}"
                paginateButton="#{true}"
                paginationControls="#{true}"
                title="#{msgs.table1_col2_header}"
>
                <sun:dynamicColumnRowGroup
                        id="rowGroup1"
                        data={"$attribute{usageSummaryDataList}"}
                        sourceVar="tRow"
                        styleClasses="rowColor1,rowColor2"
                        columnSort="$attribute{columnSorts}"
                        columnAlign="$attribute{columnAligns}"
                        columnHeaderText="$attribute{columnHeaders}"
                        columnFooterText="$attribute{columnHeaders}"
                        columnSpacerColumn="$attribute{columnSpacers}"
                        columnWidth="$attribute{columnWidths}"
                        columnValue="$attribute{columnValues}"
                        rows="#{pageSession.tableRows}"
>
                </sun:dynamicColumnRowGroup>
            </sun:table>
    "</td></tr>
"</table>
# include "commonFooter.inc"