Ken,
This is not going to work for me as this handler takes input some
pageSession variables which gets created in beforeCreate event which
also gets updated with the ajax requests. I currently have couple of
drop downs which use ajax to update each other and then there is a
button. When a user presses that button, I need to recreate the table
(after page refresh). So I am using "command" event to call the handler
in the button and I expect it to refresh the table after the reload, but
it doesn't work. Here is my button:
<sun:button
id="generateButton"
text="#{msgs.button_generateText}"
toolTip="#{msgs.button_generateText}"
>
<!command
getTable1Data(lavaVersion="#{pageSession.lava}",
buildVersion="#{pageSession.build}",
lavaProject="#{pageSession.project}"
table1Data=>$pageSession{table1DataList});
/>
</sun:button>
So how can I make this work.
thanks
Karam
Ken Paulsen wrote:
>
> I assume you are calling your handler this in a "beforeCreate" event?
> Try moving the handler to an <!initPage /> event at the top of the page:
>
> <!initPage
> yourHandler(...);
> />
>
> Unlike "beforeCreate", "initPage" gets invoked every time the page is
> refreshed. You can probably move your List into a request attribute
> when you take this approach b/c you will be regenerating the data
> every request.
>
> I hope this helps!
>
> Ken
>
> Karam Singh Badesha wrote:
>> Found out what is happening here. Basically on my initial page load,
>> there was no data for the table. Now when I select some other entries
>> and click on a button, it is refreshing the page, but the table still
>> shows the old data (in this case, nothing). I tried the default so
>> that some data shows up and after resubmitting with different data,
>> it doesn't refresh. Can this problem be solved? I need the fix by Mon
>> as I need to demo this to our team.
>>
>> thanks
>> Karam
>>
>> Karam Singh Badesha wrote:
>>> Hi,
>>> Here is the what I had when the code was working fine:
>>>
>>> Table data was hardcoded in the handler was passing a list of
>>> HashTable/Map entries. The values is passed back and set as a
>>> pageSession variable. Here is corresponding jsf code:
>>>
>>> <sun:tableRowGroup
>>> id="rowGroup1"
>>> data={"$pageSession{table1DataList}"}
>>> sourceVar="tRow"
>>> >
>>>
>>> Now, I am getting the data from the database in the handler and can
>>> print the data fine in the handler, so I am assuming the data is
>>> getting fed into the same list of HashTable/Map entries fine. But
>>> nothing is showing up on the Table. Any idea why this might be
>>> happening?
>>>
>>> Here is the corresponding handler code:
>>>
>>> @Handler(id="getTable1Data",
>>> input={
>>> @HandlerInput(name="lavaVersion", type=String.class),
>>> @HandlerInput(name="buildVersion", type=String.class),
>>> @HandlerInput(name="lavaProject", type=String.class)},
>>> output={
>>> @HandlerOutput(name="table1Data", type=java.util.List.class)
>>> })
>>> public static void fetchTable1Data(HandlerContext context) {
>>> System.out.println("In fetchTable1Data...");
>>> String lava = (String) context.getInputValue("lavaVersion");
>>> String build = (String) context.getInputValue("buildVersion");
>>> String project = (String) context.getInputValue("lavaProject");
>>> List t1Data = new ArrayList();
>>> try {
>>> System.out.println("In fetchTable1Data try block...");
>>> DataAccessLayer dal = new DataAccessLayer();
>>> CachedRowSetImpl crs = dal.getFirstLevelUsageStats(lava,
>>> build, project);
>>> RowSetMetaDataImpl rsmd = (RowSetMetaDataImpl)
>>> crs.getMetaData();
>>> int count = rsmd.getColumnCount();
>>> System.out.println("Column count is: " +
>>> rsmd.getColumnCount());
>>> int rows = 0;
>>> while(crs.next()) {
>>> System.out.println("In while loop: " + rows);
>>> Map rEntries = new Hashtable();
>>> for(int i=1;i<=count;i++)
>>> {
>>> System.out.println(crs.getObject(i));
>>> rEntries.put("col" +i, crs.getObject(i).toString());
>>> }
>>> t1Data.add(rows,rEntries);
>>> rows++;
>>> }
>>> System.out.println("Table rows: " + rows);
>>> } catch(SQLException e) {
>>> e.printStackTrace();
>>> }
>>> // Set the output.
>>> context.setOutputValue("table1Data", t1Data);
>>> }
>>>
>>> thanks
>>> Karam