Issue 239: Don't save the worksheet
Status:  Fixed
Owner: ----
Closed:  Apr 2010
Reported by andyned...@gmail.com, Dec 29, 2009
Hello to everybody and off course Merry Christmas and Happy New Year!! ;)

I know Java and me (specially JMesa XDD) aren´t the best friends, but...
I have read very much documentation, included the Worksheet Tutorial, but
there is something don't fit. After looking for the examples with de
worksheet mode, I can't find ALL the code source it works, so really I
can't compare my code with the example. In the example Jmesa works
perfectly... this is check one, two... all you want to check, and if I go
to another page and return, I have checked the chekbox I clicked. This is
ok. The problem is that in my code it doesn't work. If my code, if a go to
another page with some checkbox checked and I return, I lost that checked.
If I make click on the icon "Save WorkSheet" it works the same way (without
checked).

Part of my code:
<div id="listadoContenido">
<%
	String check = "<input type=\"checkbox\"
onclick=\"selectAllItems('jmesa_noticias')\"/>";
%>
 <c:set var="checks"><%=check%></c:set> 

    <jmesa:tableFacade toolbar="es.opencms.jmesa.ToolbarJMesa"
id="jmesa_noticias" stateAttr="restore" maxRows="5"
maxRowsIncrements="5,10,15" 
        items="${listado}" var="noticias" editable="true"
exportTypes="jexcel,pdfp,csv">
        <jmesa:htmlTable>
            <jmesa:htmlRow uniqueProperty="id">
                <jmesa:htmlColumn property="checkbox" title="${checks}"
worksheetEditor="org.jmesa.worksheet.editor.CheckboxWorksheetEditor" 
                    filterable="false" sortable="false" width="2%" /> 
                <%--<jmesa:htmlColumn property="checkbox" title="${checks}"
worksheetEditor="es.opencms.jmesa.worksheet.SalvarCheckbox" 
                    filterable="false" sortable="false" width="2%" />--%>
                <jmesa:htmlColumn property="fecha" title="Fecha"
pattern="dd/MM/yyyy" editable="false"
cellEditor="org.jmesa.view.editor.DateCellEditor" 
                    sortable="true" width="10%" headerClass="sortable"
sortOrder="asc,desc,none" />
                <jmesa:htmlColumn property="titular"
cellEditor="es.opencms.jmesa.ficha.FilaNoticiaPinchada" title="Titular"
sortable="true" 
                    editable="false" headerClass="sortable"
sortOrder="asc,desc,none"width="70%" />
                <jmesa:htmlColumn property="prioridad"
cellEditor="es.opencms.jmesa.ficha.FilaNoticiaPinchada" filterable="true"
title="Prioridad" 
                    editable="false" sortable="true" headerClass="sortable"
sortOrder="desc,asc,none" width="8%" />
                <jmesa:htmlColumn property="visible"
cellEditor="es.opencms.jmesa.ficha.FilaNoticiaPinchada" title="Visible"
editable="false" 
                    sortable="true" width="10%"
filterEditor="es.opencms.jmesa.filtros.FiltroBooleano">
                    <img
src="<cms:link>${rutaImagen}dibujos/${noticias.mostrarVisible}</cms:link>" />
                </jmesa:htmlColumn>
            </jmesa:htmlRow>
        </jmesa:htmlTable>
    </jmesa:tableFacade> 
    
    <c:set var="rutaPrincipal"><%=rutaActual%></c:set>
    
    <script type="text/javascript">
    
        function onInvokeAction(id,action)
        {
            setExportToLimit(id, '');

            //Con este IF hacemos que sólo se pueda ordenar las columnas de
una en una, 
            //no manteniendo ordenaciones de columnas ya pinchadas
            if (action == 'sort') {
                var limit = jQuery.jmesa.getTableFacade(id).limit;
                var sortSet = limit.getSortSet();
                if (sortSet) {
                    var sort = limit.sortSet[limit.sortSet.length - 1];
                    removeAllSortsFromLimit(id)
                    limit.sortSet[0] = sort;
                }
            }
                                                    
            createHiddenInputFieldsForLimitAndSubmit(id);
        }

        function onInvokeExportAction(id,action) {
            var parameterString = createParameterStringForLimit(id);
            location.href = 'index.html?' + parameterString;
        }

        function selectAllItems(id) {
            var table = document.getElementById(id);
            var inputs = table.getElementsByTagName("input");
            var inputOption = inputs[0];
            //begin on 1 to ignore the header checkbox and count only
theother ones on the table
            for (var i = 1; i < inputs.length; i++){
                inputs[i].checked = inputOption.checked;
                //call the "submitWsCheckboxColumn" manually
                inputs[i].onclick();
            }

        } 
    </script>
</div>
-------------------------------------
Really I down know how I must work after reading the Worksheet Tutorial...
if I must creat a new clase to asign to the column with the checkbox, if
with javascript it's rules,etc.

Thanks to help me!!
This single and sad developer wish you Happy New Year from Spain!! ;)
Dec 29, 2009
Project Member #1 jeff.johnston.mn@gmail.com
When you click the checkbox it sends the checked state to the WorksheetServlet. Do
have the WorksheetServlet defined in your web.xml? Do you get any JavaScript errors?
If you use Firebug you should be able to track the request/response to the server as
you check and uncheck that column as well as see any JavaScript errors. Does that
make sense?
Status: Accepted
Dec 30, 2009
#2 andyned...@gmail.com
Thank you very for the response, Jeff. Really you've been very fast!! ;)

In the example and in my project, I've written in my code this:
<servlet>
    <servlet-name>worksheet</servlet-name>
    <servlet-class>org.jmesa.worksheet.servlet.WorksheetServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>worksheet</servlet-name>
    <url-pattern>*.wrk</url-pattern>
</servlet-mapping>

This is ok, but you were right i use Firebug to get the error. I get this message:
POST http://localhost........../Contenidos/Noticias/jmesa.wrk? 404 Not Found X 60ms

Really...Where is the file "jmesa.wrk"? I think it would be like an internal call,
but... pufff!! I don't know!! 

Your way are right Jeff. I hope you can help me to arrive to the finishing line :)

Thanks so much!!

Dec 30, 2009
#3 andyned...@gmail.com
Surprise!!!! I can't understand it XDDD After trying and trying differents ways, I
overwrite the code in WEB.XML, but it isn't successful. I returned to my old code...
<servlet>
    <servlet-name>worksheet</servlet-name>
    <servlet-class>org.jmesa.worksheet.servlet.WorksheetServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>worksheet</servlet-name>
    <url-pattern>*.wrk</url-pattern>
</servlet-mapping>
....
And... TACHAAAAAAAAAAAAAN!! Firebug dont show me any error. This is a little victory.
Unfortunately if I go to another page or make click on the icon to Save The
Worksheet, all I've checked return uncheked :(

Now Firebug can't help me. By the moment I haven't any light to guide me :)

PD: Sorry by my terrible English ;)
Dec 30, 2009
Project Member #4 jeff.johnston.mn@gmail.com
The *.wrk that you defined in the web.xml is what the JavaScript uses to post the
request. You can see this in the jquery.jmesa.js file in the submitWsColumn() method
in the worksheet section. I would put a breakpoint in there with firebug and see what
that call looks like. 

You might also want to try setting one of the other columns to be editable and see if
it is just the checkbox having problems.

To debug this further you could also either get the source code and run that in your
project, or you could attach the source code to the debugger. I tend to jump to the
source code for open source projects that I use right away because it is much easier
to debug problems. I think a lot of people forget that they can attach the source
code to the debugger too. You would start debugging at the worksheet servlet level
really to see if that even gets called like you expect.

Here is a link that you could use to run the source (from the repository) if you
choose that route, although attaching the source is a lot easier.

https://code.google.com/p/jmesa/wiki/ProjectBuild

Let me know if anything I said does not make sense and I will do what I can to help.
I am sorry that this is giving you so much trouble as that has been a very popular
feature.

Jan 11, 2010
#6 andyned...@gmail.com
Happy New Year!! I'm here again!! ;) I was on holydays. Right now I'll try you've
told me about my problem. Thanks for your response ;)

And don't worry!! Everythig you said me does make sense, but I'm not going so fast I
would like, because I'm a beginner programmer in Java. I read, investigate and learn
so fast I can but.... :D
Jan 11, 2010
#7 andyned...@gmail.com
I've get an error with Firebug:

org.opencms.file.CmsVfsResourceNotFoundException: Error leyendo recurso desde la ruta
"/PANEL_MUNICIPIOS/es/Contenidos/Noticias/jmesa.wrk".
	at
org.opencms.file.CmsVfsResourceNotFoundException.createException(CmsVfsResourceNotFoundException.java:78)
	at org.opencms.db.CmsDbContext.throwException(CmsDbContext.java:238)
	at org.opencms.db.CmsDbContext.report(CmsDbContext.java:212)
	at org.opencms.db.CmsSecurityManager.readResource(CmsSecurityManager.java:4036)
	at org.opencms.file.CmsObject.readResource(CmsObject.java:3529)
	at org.opencms.file.CmsObject.readResource(CmsObject.java:3496)
	at org.opencms.file.CmsObject.readDefaultFile(CmsObject.java:2698)
	at org.opencms.main.OpenCmsCore.initResource(OpenCmsCore.java:1384)
	at org.opencms.main.OpenCmsCore.showResource(OpenCmsCore.java:1521)
	at org.opencms.main.OpenCmsServlet.doGet(OpenCmsServlet.java:152)
	at org.opencms.main.OpenCmsServlet.doPost(OpenCmsServlet.java:164)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.opencms.file.CmsVfsResourceNotFoundException: No se pudo leer el
recurso "/PANEL_MUNICIPIOS/es/Contenidos/Noticias/jmesa.wrk".
	at org.opencms.db.generic.CmsVfsDriver.readResource(CmsVfsDriver.java:1937)
	at org.opencms.db.CmsDriverManager.readResource(CmsDriverManager.java:6462)
	at org.opencms.db.CmsSecurityManager.readResource(CmsSecurityManager.java:5849)
	at org.opencms.db.CmsSecurityManager.readResource(CmsSecurityManager.java:4034)
	... 21 more
-----------------------
Really, when I make click on a chekbox, the console of Firebug doesn't report an
error with de the file jmesa.wrk, but if I look for in the options "Header", "Send"
and "Response" in the Console, I can get that error in the last option ("RESPONSE").
All the code is the attached file.
error.zip
2.0 KB   Download
Jan 13, 2010
#8 andyned...@gmail.com
Well... All my problems are solved. I've just seen there was a new version of jmesa
(2.4.6). Actually my project runs with this version, and all the errors are
disappeared. The Murphy's Law says "don't toch if it's right", so I won't toch
ANYTHING MORE :D. Now I've anothers errors, but this history is diferent :)

Thank you for your prized time and your interest! ;)
Apr 13, 2010
Project Member #9 jeff.johnston.mn@gmail.com
(No comment was entered for this change.)
Status: Fixed