Jmesa and Struts 2 Action

301 views
Skip to first unread message

Lorie

unread,
Mar 9, 2012, 2:07:38 PM3/9/12
to jmesa_forum
I am having a problem with saving the worksheet changes for my Jmesa
table, everything displays correctly, but I can not get inside the
saveWorksheetChanes code. below is my code:

I've left out some of the code, let me know if the other code is
needed as well:

public class BidProjectSheetAction extends MainAction {
public String execute() {

request =
(HttpServletRequest)ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
TableModel tableModel = new TableModel("projects", request);
tableModel.setEditable(true);
tableModel.setItems(lanes);
tableModel.setMaxRows(100);

tableModel.saveWorksheet( new WorksheetSaver() {
public void saveWorksheet(Worksheet worksheet) {
saveWorksheetChanges(worksheet);
}
});
tableModel.setTable(generateTable());
setTableData(tableModel.render());
return "success";
}


protected void saveWorksheetChanges(Worksheet worksheet){
Collection<WorksheetRow> rows = worksheet.getRows();
for (WorksheetRow worksheetRow : rows){
if (worksheetRow.getRowStatus().equals(WorksheetRowStatus.MODIFY) )
{
Collection<WorksheetColumn> columns = worksheetRow.getColumns();
for (WorksheetColumn worksheetColumn : columns){
String changedValue = worksheetColumn.getChangedValue();
String rate =
worksheetRow.getColumn("ratePerMile").getChangedValue();
System.out.println("Rate is: " + rate);
}
}
}
}

The problem is I never can get inside the saveWorksheetChanges method,
my callback always goes inside the execute method. If I call
saveWorksheetDirectly the Worksheet is not passed in..

Lorie

unread,
Mar 9, 2012, 2:46:57 PM3/9/12
to jmesa_forum
Also wanted to post my .jsp

<form name="projectsForm" action="${pageContext.request.contextPath}/
carrier/bid-project-sheet">
<div id="projects">
${tableData}
</div>
</form>
function onInvokeAction(id, action)
{
setExportToLimit(id, '');
//var parameterString =
createHiddenInputFieldsForLimitAndSubmit(id);
var parameterString = createParameterStringForLimit(id);
location.href='${pageContext.request.contextPath}/carrier/bid-
project-sheet?' + parameterString + "&id=" + <%=
request.getParameter("id") %>;
}


On Mar 9, 2:07 pm, Lorie <loriemoff...@gmail.com> wrote:
> I am having a problem with saving the worksheet changes for my Jmesa
> table, everything displays correctly, but I can not get inside the
> saveWorksheetChanes code. below is my code:
>
> I've left out some of the code, let me know if the other code is
> needed as well:
>
> public class BidProjectSheetAction extends MainAction {
>         public String execute() {
>
>                 request =
> (HttpServletRequest)ActionContext.getContext().get(StrutsStatics.HTTP_REQUE­ST);

Lorie

unread,
Mar 9, 2012, 5:19:39 PM3/9/12
to jmesa_forum
If I could get the worksheet from the session that would be just
fine.. I have tried with no success..

using different variations of this code:
request =
(HttpServletRequest)ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
TableFacade tableFacade =
TableFacadeFactory.createTableFacade("projects", request);
//TableModel tableModel = new TableModel("projects", request);
WorksheetState sess = new
SessionWorksheetState("this_list",tableFacade.getWebContext());

Worksheet worksheet =
(Worksheet)request.getAttribute("projectss_WORKSHEET");
Worksheet worksheet2 = sess.retrieveWorksheet();

Jeff Johnston

unread,
Mar 9, 2012, 8:41:28 PM3/9/12
to jmesa...@googlegroups.com
Hi.

Did you wire up the WorksheetServlet?

Can I see what your generateTable() method looks like?

-Jeff Johnston

Jeff Johnston

unread,
Mar 9, 2012, 8:50:11 PM3/9/12
to jmesa...@googlegroups.com
Also, do you use Firebug? If so what you could do is see if the WorksheetServlet is being called when you edit a column. It might be helpful to post the URL for one of those calls as well.

-Jeff Johnston

Lorie

unread,
Mar 10, 2012, 10:27:23 AM3/10/12
to jmesa_forum
OH YEAH! It is working now! I did not have the servlet hooked up
properly, Thanks so much!

lORIE

On Mar 9, 8:50 pm, Jeff Johnston <jeff.johnston...@gmail.com> wrote:
> Also, do you use Firebug? If so what you could do is see if the
> WorksheetServlet is being called when you edit a column. It might be
> helpful to post the URL for one of those calls as well.
>
> -Jeff Johnston
>
> On Fri, Mar 9, 2012 at 7:41 PM, Jeff Johnston <jeff.johnston...@gmail.com>wrote:
>
>
>
> > Hi.
>
> > Did you wire up the WorksheetServlet?
>
> > Can I see what your generateTable() method looks like?
>
> > -Jeff Johnston
>
> > On Fri, Mar 9, 2012 at 4:19 PM, Lorie <loriemoff...@gmail.com> wrote:
>
> >> If I could get the worksheet from the session that would be just
> >> fine.. I have tried with no success..
>
> >> using different variations of this code:
> >> request =
>
> >> (HttpServletRequest)ActionContext.getContext().get(StrutsStatics.HTTP_REQUE­ST);
Reply all
Reply to author
Forward
0 new messages