ecco un frammento di una jsp:
ed ecco un esempio abbastanza "brutale" di un decorator: questo ritorna la stringa html corrispondente ad un'icona di edit che, premuta, manda alla form di modifica...codice:<display-el:table name="${requestScope.results}" id="parametroRibaltamento" class="browse" export="${userCtx.exportableTables}" decorator="it.html.tables.decorator.ParametroRibaltamentoBrowseTableDecorator" pagesize="999"> <display-el:column titleKey="xxxx.title.column.commessa" sortable="true"> <display-el:column media="html" property="addActionsLinks" titleKey="aragorn.collabel.actions"/> </display-el:table>
codice:public class ParametroRibaltamentoBrowseTableDecorator extends TableDecorator { private static final String IMG_PATH_REF = AppCtxKeys.BASE_IMAGES_PATH; private static final String IMG_UPDATE_REF = "/edit.gif"; private static final String UPDATE_PAGE = "/protected/parametroRibaltamentoBrowse.jsp"; private static final String FORM_NAME = "ParametroRibaltamentoChangeForm"; public String getAddActionsLinks() { String id = null; String pianoContiId = null; HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest(); String annoEsercizio = request.getParameter("annoEsercizio"); try { id = (String) PropertyUtils.getProperty(this.getCurrentRowObject(), "id"); pianoContiId = (String) PropertyUtils.getProperty(this.getCurrentRowObject(), "pianoContiId"); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } return "<a href=\"" + UPDATE_PAGE + "?id=" + id + "&pianoContiId=" + pianoContiId + "&op=update" + "&opspec=tblinl&form=" + FORM_NAME + "&annoEsercizio=" + annoEsercizio + "\">" + "<img id=\"actionimg\" src=\"" + IMG_PATH_REF + IMG_UPDATE_REF + "\" title=\"" + UtilityKeys.TITLE_UPDATE + "\"></a>"; } }

Rispondi quotando