My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 233: RowEvent onclick, but get de column clicked
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Mar 2011


 
Reported by andyned...@gmail.com, Nov 30, 2009
Hi!! I've tryed get the column when I clicked on a row, but i can't get it.
After reading very much documentation, i can't solve the problem. I've made
a class extends from AbstractRowEvent:

@Override
public String execute(Object item, int rowcount) {
   System.out.println("***********" +
this.getRow().getColumn("checkbox").getProperty().toString());
   Object bean = ItemUtils.getItemValue(item, "news");
   Object nombreFichero = ItemUtils.getItemValue(bean, "fileName");
   return "javascript:document.getElementById('ruta').value='" +
nombreFichero.toString() + "';
javascript:document.getElementById('action').value='create';
javascript:document.pag_frm.submit();";
}

I have a column with checkbox, and if I click on any column of therow or
over the checkbox on the row, it work the same way. I want to differentiate
between make click on a checkbox or make click on the rest of columns. That
trace i write on the code (System.out.println("***********" +
this.getRow().getColumn("checkbox").getProperty().toString());) always show
me the first column (the checkbox in my case), so it isn't good for my mode
work. I can't to manage to differentiate the columns I click on.

I hope you can understand my case. My english isn't very good... sorry!!! :)

I tryed to use to the class ColumnEvent, but always I get an exception
because "jmesa:htmlRow" and "jmesa:htmlColumn" don't admit that class.
Where can I use that class to??

Thanks so much for you attention!!!
Nov 30, 2009
Project Member #1 jeff.johnston.mn@gmail.com
The only way that you are going to know what column was clicked would be to put a
JavaScript event on the column. I think you are going to have to either create a
custom cell editor for each column to do it, or use jQuery and bind an event on load
of the page.

I wish I had a more direct answer for you but what you are tying to do is pretty
custom...although very possible.
Dec 1, 2009
#2 presiden...@gmail.com
Thanks for you response. I'll try take a way to solve this problem with yours
indications. If I get it, I'll tell you and everybody. I hope.... :)
Dec 1, 2009
#3 andyned...@gmail.com
At the end i solved the problem. I followed the indications (thanks so much Jeff!!)
and I've guided the solution with CellEditor. My custom class is...

import org.jmesa.util.ItemUtils;
import org.jmesa.view.editor.AbstractCellEditor;
import org.jmesa.view.html.HtmlBuilder;

public class FilaNoticiaPinchada extends AbstractCellEditor {

	@Override
	public Object getValue(Object item, String property, int rowcount) {
        Object value = ItemUtils.getItemValue(item, property);
        
        Object bean = ItemUtils.getItemValue(item, "news");
        Object nombreFichero = ItemUtils.getItemValue(bean, "fileName");
        HtmlBuilder html = new HtmlBuilder();
        html.div().onclick("javascript:document.getElementById('ruta').value='" +
fileName.toString() + "';
javascript:document.getElementById('action').value='create';
javascript:document.pag_frm.submit();").close();
        html.append(value);
        html.divEnd();
        return html.toString();
    }
}


In this way I show the same information, and I choose the columns I want to be clicked:

<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}"  editable="true"
worksheetEditor="org.jmesa.worksheet.editor.CheckboxWorksheetEditor"
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.sopde.opencms.jmesa.filtros.FiltroBooleano"><img
src="<cms:link>${rutaImagen}dibujos/${noticias.mostrarVisible}</cms:link>"
/></jmesa:htmlColumn> 
        </jmesa:htmlRow>
    </jmesa:htmlTable>
</jmesa:tableFacade>


I hope this solution can be used to anyone with the same problem I had.
Mar 10, 2011
Project Member #4 jeff.johnston.mn@gmail.com
(No comment was entered for this change.)
Status: Fixed

Powered by Google Project Hosting