jmesa:htmlRow onclick event

301 views
Skip to first unread message

Sergio B.

unread,
Mar 21, 2012, 12:47:05 PM3/21/12
to jmesa_forum, javier...@gmail.com
Hi there,

I have working with Jmesa since a week ago. At this moment I am trying
to get the event that is fired when a row is clicked.
My Jmesa code is

<s:hidden name="tabla" id="tabla" />
<s:hidden name="idInput" id="idInput" />
<s:hidden name="idColumnas" id="idColumnas" />
<s:hidden name="cabecerasColumnas" id="cabecerasColumnas" />
<c:set var="contador" value="0" />
<c:set var="listaCabeceras" value="${fn:split(cabecerasColumnas,
',')}" />
<c:set var="miCheckbox" value="true" />

<jmesa:struts2TableModel items="${listaDatos}" id="${idInput}"
var="bean">
<jmesa:htmlTable width="100%">
<jmesa:htmlRow
onclick="com.meyss.subv.actions.jmesa.OnClickRowEvent">

<c:forEach var="idColumna" items="${fn:split(idColumnas, ',')}">

<jmesa:htmlColumn property="${idColumna}"
title="${listaCabeceras[contador]}" headerClass="sortable"
sortOrder="asc,desc,none"
filterEditor="org.jmesa.view.html.editor.DroplistFilterEditor" /
>

<c:set var="contador" value="${contador + 1}" />

</c:forEach>
</jmesa:htmlRow>
</jmesa:htmlTable>
</jmesa:struts2TableModel>

And I have developed com.meyss.subv.actions.jmesa.OnClickRowEvent that
implements org.jmesa.view.html.event.RowEvent.

But no event, when a row is clicked, is fired. I only get a onclick
event fired when the headers of the table is clicked on.

Any help would be very appreciated!!

regards,

Sergio



Jeff Johnston

unread,
Mar 22, 2012, 12:22:26 AM3/22/12
to jmesa...@googlegroups.com

I do not think the foreach loop will work to define dynamic columns (at least to my knowledge). The better way to do it would be to use the HtmlColumnsGenerator interface.

http://code.google.com/p/jmesa/wiki/HtmlColumnsGenerator

Note though that the HtmlComponentFactory is deprecated as you can now just create your own columns directly.

HtmlColumn
firstName = new HtmlColumn("name.firstName");

Then for the onclick do you see anything when you view the source of the page?

-Jeff Johnston

Sergio B.

unread,
Mar 22, 2012, 6:00:31 AM3/22/12
to jmesa...@googlegroups.com
Hi Jeff,

many thanks for your answer and your advice.

The source code generated by my code is the following (I have attached the headers and one data row):
<TR class=header>
<TD class=sortable>
<DIV onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" onclick="jQuery.jmesa.addSortToLimit('orden.idEjercicio','0','codigo','asc');onInvokeAction('orden.idEjercicio', 'sort')">
Código
</DIV>
</TD>
<TD class=sortable>
<DIV onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" onclick="jQuery.jmesa.addSortToLimit('orden.idEjercicio','1','descripcion','asc');onInvokeAction('orden.idEjercicio', 'sort')">
Descripción
</DIV>
</TD>
</TR>
</THEAD>
<TBODY class=tbody>
<TR id=orden.idEjercicio_row1 class=odd onmouseover="this.className='highlight'" onmouseout="this.className='odd'">
<TD>2005</TD>
<TD>2005</TD>
</TR>

And in the whole generated code there is no reference to my method onclick.

Do I missing anything?

Many thanks.

Sergio

Jeff Johnston

unread,
Mar 23, 2012, 12:10:10 AM3/23/12
to jmesa...@googlegroups.com
Somtime within the week I will run a test to make sure that functionality still works. It has been awhile since I have used it in my apps, but it should still work. I will let you know what I find!

-Jeff

Sergio B.

unread,
Apr 12, 2012, 9:30:54 AM4/12/12
to jmesa...@googlegroups.com
Hi Jeff,

I am writting to you  just to know if you get anything about it?

Many thanks in advance

regards,

Sergio

Jeff Johnston

unread,
Apr 25, 2012, 5:13:17 PM4/25/12
to jmesa...@googlegroups.com
Sorry for the late reply :(.

I finally got back to working on JMesa and I did a quick test to see if the onclick worked. It did for me...this is what my RowEvent looks like.

        htmlRow.setOnclick(new RowEvent() {
            public String execute(Object item, int rowcount) {
                return "alert('hello world')";
            }
        });

It could be a tag problem though...I will try that next.

-Jeff

Jeff Johnston

unread,
Apr 26, 2012, 11:00:41 AM4/26/12
to jmesa...@googlegroups.com
Seems to work fine with tag as well...

<jmesa:htmlRow onclick="com.roomandboard.admin.view.MyRowEvent">


public class MyRowEvent implements RowEvent {

    public String execute(Object item, int rowcount) {
        return "alert('hello world')";
    }
}

-Jeff
Reply all
Reply to author
Forward
0 new messages