Thanks Ken.
I just added the count information to the url string in the beginning
and it works fine now. Can't believe how much time it took to figure
this out. Now the only problem left is the AJAX problem with the new
woodstock components :) Were you able to see the problem on that page?
thanks again
-Karam
Ken Paulsen wrote:
>
> Suppose your data is something like:
>
> List<Map<String,String>> datamodel:
>
> col1: <a href="foo.jsf?row=1">1</a>
> col2: <a href="foo.jsf?row=1">Z</a>
> col1: <a href="foo.jsf?row=2">2</a>
> col2: <a href="foo.jsf?row=2">A</a>
> col1: <a href="foo.jsf?row=3">3</a>
> col2: <a href="foo.jsf?row=3">M</a>
>
>
> If you simply display column 1 in column 1 of your table, then sort
> column 1... no problem. If you display/sort column 2, problem.
> Column 2's embedded href url has 1,2,3 in it which will effect the
> sort (so it will ignore the ordering of the visible parts Z, A, M).
>
> To fix this, if you add the following data to your dataset (and btw,
> this is the reason I created the MulitpleListDataProvider), then you
> can fix this:
>
> List<Map<String, String>> sortdatamodel:
>
> col1sort: 1
> col2sort: Z
> col1sort: 2
> col2sort: A
> col1sort: 3
> col2sort: M
>
>
> Then in your JSF page:
>
> <sun:dynamicColumnRowGroup ... data={"$attribute{datamodel}",
> "$attribute{sortdatamodel}"} columnSort={"col1sort", "col2sort"} ... />
>
> I hope that's the problem and this fixes it! :)
>
> Good luck,
>
> Ken
>
>
>
> Karam Singh wrote:
>> Ken,
>> I modified your example and added the same kind of hyperlink string
>> in the data and the sorting worked fine.
>> Also in the table, actual value in the cell is a number (in string
>> form).
>>
>> In the string that I am constructing:
>> <a href=usageReportDetail.jsf?lava=" +lava+ "&build=" +build+
>> "&project=" +project+ "&tool=" +toolName+ "
>>
>> everything before toolName is constant and then toolName changes in
>> every row and is the first column value. So I guess it would make
>> sense if its doing that.
>>
>> >If this is the case, make sure you have a sort key in your model for
>> each row and use that.
>> How is this done? small example?
>>
>> thanks
>> Karam
>>
>> Ken Paulsen wrote:
>>>
>>> Hi Karam,
>>>
>>> That could indeed be the problem as that is the String that is being
>>> compared. If an earlier value (say "lava" for example) is constant
>>> across your columns, but changes per row. It will determine the
>>> sort order for all of them, making it appear to sort the first
>>> column in all cases. If this is the case, make sure you have a sort
>>> key in your model for each row and use that.
>>>
>>> On an unrelated topic, did I ever mention that I'm jealous that your
>>> project uses the name "lava"? :) That was the original name of
>>> JSFTemplating before lawyers killed it. :(
>>>
>>> I hope this solves your problem!
>>>
>>> Ken
>>>
>>> Karam Singh wrote:
>>>> Now that you mentioned if the data is string, even though I am
>>>> declaring it as String in java code. I am actually creating a html
>>>> string. Do you think that might be the problem? Here is the string
>>>> that I am creating for the columns which don't sort:
>>>>
>>>> tmp = "<a href=usageReportDetail.jsf?lava=" +lava+ "&build="
>>>> +build+ "&project=" +project+ "&tool=" +toolName+ "&feature=All>"
>>>> +entry+ "</a>";
>>>>
>>>> thanks
>>>> Karam
>>>>
>>>> Ken Paulsen wrote:
>>>>>
>>>>> Hi Karam,
>>>>>
>>>>> Yes I did write a test page, which I sent to you when I first
>>>>> created the dynamic table factory. I modified this test page to
>>>>> ensure sorting works as expected. In my test case, it does work.
>>>>> Here is the page:
>>>>>
>>>>> <!initPage
>>>>>
>>>>> ######################
>>>>> ## CREATE DATA ##
>>>>> ######################
>>>>>
>>>>> // Row 1
>>>>> createMap(result=>$attribute{row1});
>>>>> mapPut(map="$attribute{row1}" key="a" value="Ken");
>>>>> mapPut(map="$attribute{row1}" key="b" value="A");
>>>>> mapPut(map="$attribute{row1}" key="c" value="Paulsen");
>>>>> // Row 2
>>>>> createMap(result=>$attribute{row2});
>>>>> mapPut(map="$attribute{row2}" key="a" value="Jaye");
>>>>> mapPut(map="$attribute{row2}" key="b" value="L");
>>>>> mapPut(map="$attribute{row2}" key="c" value="Jurhs");
>>>>> // Row 3
>>>>> createMap(result=>$attribute{row3});
>>>>> mapPut(map="$attribute{row3}" key="a" value="Mike");
>>>>> mapPut(map="$attribute{row3}" key="b" value="C");
>>>>> mapPut(map="$attribute{row3}" key="c" value="Doe");
>>>>>
>>>>> // Create List of Map (List of the rows)
>>>>> setAttribute(key='listOfRows' value={"$attribute{row1}"
>>>>> "${row2}" "${row3}"} );
>>>>>
>>>>> />
>>>>>
>>>>> <sun:page>
>>>>> <sun:html>
>>>>> <sun:head id="head" />
>>>>> <sun:body>
>>>>> <sun:form id="form">
>>>>>
>>>>> <sun:table id="basicTable" title="Basic Table">
>>>>> <sun:dynamicColumnRowGroup id="rowGroup1"
>>>>> data={"$attribute{listOfRows}"} sourceVar="td"
>>>>> columnHeaderText={"Col 1", "Col 2", "Col 3"}
>>>>> columnValue={"#{td.value.a}", "#{td.value.b}", "#{td.value.c}"}
>>>>> columnSort={"a", "b", "c"}>
>>>>> </sun:dynamicColumnRowGroup>
>>>>> </sun:table>
>>>>>
>>>>> </sun:form>
>>>>> </sun:body>
>>>>> </sun:html>
>>>>> </sun:page>
>>>>>
>>>>> I think the main thing to ensure for the Woodstock Table's sorting
>>>>> is the column sorting key. Make sure that is correct and it
>>>>> should work. Also the data that you are sorting must be available
>>>>> when the Woodstock table performs its sorting.
>>>>>
>>>>> I'm not a table expert, though... so if the above doesn't help,
>>>>> we'll probably need to invite Dan L. to the conversation (or just
>>>>> post to the dev_at_woodstock alias). The part where JSFT is involved
>>>>> is strictly in creating the proper UIComponents and setting their
>>>>> properties (which are just passed through from whatever you set).
>>>>> You can see this is happening in the above case. I can see it's
>>>>> not working on the url you sent, but I don't see why from the code
>>>>> you provided. Your handler code seems to be providing a list
>>>>> equivalent to the {"a", "b", "c"} one I provided above, yet it
>>>>> doesn't work.
>>>>>
>>>>> The only notable thing I see different is that I initialize the
>>>>> data in initPage. If you are initializing it too late, it might
>>>>> not sort at all, or perform some default sort (Dan might be able
>>>>> to answer this).
>>>>>
>>>>> Suggestions to try... mock up your data like I did above, see if
>>>>> that fixes it. If yes, debug your data to ensure it is correctly
>>>>> available at all times and that its context is complete and
>>>>> correct. If no, look at the how you're declaring your component,
>>>>> make sure keys are matching up correctly with your data, and
>>>>> continue to debug the component itself. Are the values in the
>>>>> columns Strings? If not, do they have correct equals() methods?
>>>>>
>>>>> Sorry I'm not being more help... but I'm fishing for the answer.
>>>>>
>>>>> Ken
>>>>>
>>>>>
>>>>>
>>>>> Karam Singh wrote:
>>>>>> Ken,
>>>>>> None of the request variables were used for the table data.
>>>>>> Anyway, I have gone ahead and changed all the attribute variables
>>>>>> that were used to pageSession variables and the result is still
>>>>>> the same.
>>>>>>
>>>>>> Did you ever write the test page (with dummy data) to test
>>>>>> dynamicTable. I think doing that test to see if the sorting works
>>>>>> could be a good test.
>>>>>>
>>>>>> http://svl3.sfbay.sun.com:8080/CADRe-test/usageReport.jsf
>>>>>>
>>>>>> thanks
>>>>>> Karam
>>>>>>
>>>>>> Ken Paulsen wrote:
>>>>>>>
>>>>>>> Hi Karam,
>>>>>>>
>>>>>>> I tried the link you sent, but wasn't able to connect.
>>>>>>>
>>>>>>> Looking at this again, I can only think to say what I said last
>>>>>>> time re: request-scope. Did you try using pageSession / session
>>>>>>> to see if this changed things? Or did you try initPage? Even
>>>>>>> if the data appears to still be there after a refresh, that
>>>>>>> doesn't mean it didn't get populated via the restoreState call
>>>>>>> which always happens, but may happen after the table does its
>>>>>>> sorting (not sure... I don't know how Woodstock does this).
>>>>>>>
>>>>>>> Perhaps we can talk on the phone about this more later today
>>>>>>> (I'm on another call for the next 10-15 minutes).
>>>>>>>
>>>>>>> Ken
>>>>>>>
>>>>>>> Karam Singh Badesha wrote:
>>>>>>>> Ken,
>>>>>>>>
>>>>>>>> Any update. This is little urgent so if we could get the fix by
>>>>>>>> the end of this week it would be great.
>>>>>>>>
>>>>>>>> Also the updated link to see the app is now:
>>>>>>>> http://svl3.sfbay.sun.com:8080/CADRe-test/usageReport.jsf
>>>>>>>>
>>>>>>>> thanks
>>>>>>>> Karam
>>>>>>>>
>>>>>>>> Karam Singh wrote:
>>>>>>>>> Ken,
>>>>>>>>> The data is still there if even clicking on sort was doing
>>>>>>>>> page refresh. Here is the url of the actual page:
>>>>>>>>>
>>>>>>>>> http://svl1.sfbay.sun.com:8080/CADRe-test/usageReport.jsf
>>>>>>>>>
>>>>>>>>> If you click on sort for any column except first one, you will
>>>>>>>>> see that it always sort just the first column. Please help.
>>>>>>>>>
>>>>>>>>> thanks
>>>>>>>>> Karam
>>>>>>>>>
>>>>>>>>> Ken Paulsen wrote:
>>>>>>>>>>
>>>>>>>>>> Hi Karam,
>>>>>>>>>>
>>>>>>>>>> Sorry it took me so long to respond. I looked at your
>>>>>>>>>> code... and from just looking at it, I don't see anything
>>>>>>>>>> that jumps out as being incorrect.
>>>>>>>>>>
>>>>>>>>>> Hmm... actually looking at your page again, I see you're
>>>>>>>>>> using a beforeCreate event. This event is triggered before
>>>>>>>>>> something is created (as the name suggests). On a page
>>>>>>>>>> refresh (as done when you click a sort link), it won't
>>>>>>>>>> re-execute anything. While you are storing a lot in
>>>>>>>>>> pageSession, you are storing some things in request
>>>>>>>>>> attributes. The request attributes will not be available
>>>>>>>>>> when the page is resubmitted. Perhaps the code handling the
>>>>>>>>>> sort needs access to that information again? I'm not sure
>>>>>>>>>> that is the case, but you might try changing to pageSession
>>>>>>>>>> to see if that fixes it. Or use the initPage event (must go
>>>>>>>>>> at the top of the page) for this handler.
>>>>>>>>>>
>>>>>>>>>> If that doesn't help, we'll have to look more closely at what
>>>>>>>>>> is happening when the sort link is clicked to see why it's
>>>>>>>>>> not working.
>>>>>>>>>>
>>>>>>>>>> Ken
>>>>>>>>>>
>>>>>>>>>> Karam Singh wrote:
>>>>>>>>>>> Ken,
>>>>>>>>>>> Were you able to figure out the problem?
>>>>>>>>>>>
>>>>>>>>>>> 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
>>>>>>>>