struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paweł Wielgus" <poulw...@gmail.com>
Subject Re: Getter Method call twice - S2
Date Mon, 08 Dec 2008 17:04:38 GMT
Hi Eugenio,
i just tried to replicate Your problem,
the thing is that i remember in S1 (don't know which version) that was
normal behavior,
getter was called n times where n is list.size() - more or less.

But in S2 i don't see it anymore.
So if You want to find what's going on try to add some debuging.

Best greetings,
Paweł Wielgus.


2008/12/5 Felipe Lorenz <felipe.lorenz@gmail.com>:
> Did you try to debug your application? Or try to see from what
> Action/JSP its called! Or create a Interceptor to print a log:
>
> public class Log4JInterceptor extends AbstractInterceptor {
>
>    @Override
>    public String intercept(ActionInvocation invocation) throws Exception {
>        String comando = invocation.getInvocationContext().getName();
>        Map parametros = invocation.getInvocationContext().getParameters();
>        Map sessao = invocation.getInvocationContext().getSession();
>
>        String loginUsuario = "anonimo";
>        if( sessao.containsKey(SessionSuport.USER_SESSION) ) {
>            Colaborador colaborador = (Colaborador) sessao.get(
> SessionSuport.USER_SESSION );
>            loginUsuario = colaborador.getLogin();
>        }
>
>        String linhaLog = "";
>        Logger log = Logger.getLogger( comando );
>        String retorno = invocation.invoke();
>
>        if( !retorno.equals("erro") ) {
>            for( Object chave : parametros.keySet() ) {
>                Object valor = parametros.get( chave );
>                String valorStr = "";
>                if( valor instanceof String[] ) {
>                    for( String atual : ((String[])valor) )
>                        valorStr += atual + ",";
>                }
>                valorStr = valorStr.substring( 0, valorStr.length()-1 );
>                linhaLog += chave + "=" + valorStr + ";";
>            }
>            linhaLog = linhaLog.trim();
>
>            if( !linhaLog.equals("") ) {
>                PatternLayout layout = new PatternLayout(
> "%d{HH:mm:ss} - " + loginUsuario + " - %c - %m%n" );
>
>                String formatoData = "dd-MM-yyyy";
>                SimpleDateFormat sdf = new SimpleDateFormat( formatoData );
>                String hoje = sdf.format( new Date() );
>
>                String nomeArquivo = "logGerAtividade.log";
>
>                DailyRollingFileAppender appender = new
> DailyRollingFileAppender( layout, nomeArquivo, "dd-MM-yyyy" );
>                appender.setEncoding( "ISO-8859-1" );
>
>                ConsoleAppender consoleAppender = new ConsoleAppender(
> layout, "System.out" );
>                consoleAppender.setEncoding( "ISO-8859-1" );
>
>                log.addAppender( appender );
>                log.addAppender( consoleAppender );
>
>                log.info( linhaLog );
>
>                log.removeAllAppenders();
>            }
>        } else {
>            ActionSupport action = ActionSupport.class.cast(
> invocation.getAction() );
>            Collection erros = action.getActionErrors();
>            for( Object erro : erros ) {
>                linhaLog += erro + ",";
>            }
>
>            linhaLog = linhaLog.substring( 0, linhaLog.length()-1 );
>
>            if( !linhaLog.equals("") ) {
>                PatternLayout layout = new PatternLayout(
> "%d{HH:mm:ss} - " + loginUsuario + " - %c - %m%n" );
>                String formatoData = "dd-MM-yyyy";
>                SimpleDateFormat sdf = new SimpleDateFormat( formatoData );
>                String hoje = sdf.format( new Date() );
>
>                String nomeArquivo = "logGerAtividadeERROR.log";
>
>                DailyRollingFileAppender appender = new
> DailyRollingFileAppender( layout, nomeArquivo, "dd-MM-yyyy" );
>                appender.setEncoding( "ISO-8859-1" );
>
>                ConsoleAppender consoleAppender = new ConsoleAppender(
> layout, "System.out" );
>                consoleAppender.setEncoding( "ISO-8859-1" );
>
>                log.addAppender( appender );
>                log.addAppender( consoleAppender );
>
>                log.info( linhaLog );
>
>                log.removeAllAppenders();
>            }
>        }
>        return retorno;
>    }
>
> }
>
> On Fri, Dec 5, 2008 at 9:07 AM, Eugenio Perrotta Neto
> <eugenio.perrottaneto@gmail.com> wrote:
>> anybody has the answer?
>>
>> On Thu, Dec 4, 2008 at 2:05 PM, Eugenio Perrotta Neto <
>> eugenio.perrottaneto@gmail.com> wrote:
>>
>>> the code is here:
>>>
>>>
>>>
>>> i have a tag file called page.tag
>>>
>>>
>>> <%@ tag body-content="scriptless" %>
>>> <%@ tag pageEncoding="UTF-8" %>
>>> <%@taglib prefix="s" uri="/struts-tags" %>
>>> <%@taglib prefix="sicat2" uri="/WEB-INF/sicat2.tld"  %>
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
>>> http://www.w3.org/TR/html4/loose.dtd">
>>> <html>
>>>     <head>
>>>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
>>> />
>>>         <link rel="stylesheet" href="<s:url value='/css/main.css'
>>> includeParams='none'  encode='false' namespace="/" />" type="text/css"/>
>>>         <link rel="shortcut icon" href="<s:url
>>> value='/images/favicon.ico'/>" />
>>>         <title><s:property value="appName" /> : <s:property
>>> value="moduleName" /> : <s:property value="pageTitle" /></title>
>>>         <SCRIPT src="<s:url value='/js/lib/prototype/
>>> prototype-1.6.0.3.js' includeParams='none' />" charset="UTF-8"
>>> type="text/javascript"></SCRIPT>
>>>         <SCRIPT src="<s:url value='/js/common.js' includeParams='none'/>"
>>> charset="UTF-8" type="text/javascript"></SCRIPT>
>>>     </head>
>>>     <body class="sicat2">
>>>         <table width="100%">
>>>             <tr><td><h1 id="pageTitle"><s:property value="moduleName"/>
:
>>> <s:property value="pageTitle"/></h1></td></tr>
>>>             <tr><td><jsp:doBody /></td></tr>
>>>         </table>
>>>     </body>
>>> </html>
>>>
>>>
>>>
>>>
>>> and i have a jsp whit the code:
>>>
>>>
>>> <%@ page language="java" contentType="text/html; charset=UTF-8"
>>> pageEncoding="UTF-8"%>
>>>
>>> <%@ taglib prefix="ui" tagdir="/WEB-INF/tags"%>
>>> <%@ taglib prefix="s" uri="/struts-tags" %>
>>> <%@ taglib prefix="sicat2" uri="/WEB-INF/sicat2.tld" %>
>>> <%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
>>>
>>> <ui:page>
>>>     <sicat2:toolbar>
>>>         <sicat2:submitButtom action="MaterialServicoList" label="Filtrar"
>>> image="/images/icons/filter.png" />
>>>         <sicat2:actionButtom action="MaterialServicoAdd" label="Novo"
>>> image="/images/icons/add.png" />
>>>     </sicat2:toolbar>
>>>     <fieldset>
>>>         <legend>Filtro</legend>
>>>         <s:form>
>>>             <s:radio label="Situação" list="situacoes"
>>> name="filterSituacao" />
>>>         </s:form>
>>>     </fieldset>
>>>     <display:table name="list" id="materialServico"
>>> cellspacing="0">
>>>         <display:column property="numero"  sortName="numero"
>>> sortable="true" defaultorder="ascending"/>
>>>         <display:column property="descricao" sortName="descricao"
>>> sortable="true" defaultorder="ascending"/>
>>>         <display:column>
>>>             <sicat2:actionButtom action="MaterialServicoEdit"
>>> title="Editar" image="/images/icons/edit.png" >
>>>                 <sicat2:buttonParam name="materialServico.id" value="#
>>> attr.materialServico.id <http://attr.materialservico.id/>"/>
>>>             </sicat2:actionButtom>
>>>         </display:column>
>>>     </display:table>
>>> </ui:page>
>>>
>>>
>>> My action has this code:
>>>
>>> package br.com.cesan.sicat2.module.servico;
>>>
>>> import java.util.List;
>>> import java.util.Map;
>>>
>>> import org.displaytag.pagination.PaginatedList;
>>> import org.displaytag.properties.SortOrderEnum;
>>>
>>> import br.com.cesan.sicat2.domain.servico.SituacaoMaterialServico;
>>> import br.com.cesan.sicat2.util.FilterInfo;
>>> import br.com.cesan.sicat2.util.ListInfo;
>>> import br.com.cesan.sicat2.util.SortOrder;
>>>
>>> public class MaterialServicoList extends MaterialServicoBaseAction {
>>>
>>>     private SituacaoMaterialServico filterSituacao =
>>> SituacaoMaterialServico.ATIVO;
>>>
>>>     private FilterInfo filter = new FilterInfo(10, 1, "numero",
>>> SortOrder.ASC);
>>>
>>>     public void setFilter(FilterInfo filterInfo) {
>>>         this.filter = filterInfo;
>>>     }
>>>
>>>     public FilterInfo getFilter() {
>>>         return filter;
>>>     }
>>>
>>>     public PaginatedList getList(){
>>>         final ListInfo list = materialServicoService.list(getFilter());
>>>
>>>         return new PaginatedList(){
>>>             public int getFullListSize() {
>>>                 return list.getListSize();
>>>             }
>>>
>>>             public List getList() {
>>>                 return list.getList();
>>>             }
>>>
>>>             public int getObjectsPerPage() {
>>>                 return getFilter().getPageSize();
>>>             }
>>>
>>>             public int getPageNumber() {
>>>                 return getFilter().getPage();
>>>             }
>>>
>>>             public String getSearchId() {
>>>                 return "";
>>>             }
>>>             public String getSortCriterion() {
>>>                 return getFilter().getSortField();
>>>             }
>>>             public SortOrderEnum getSortDirection() {
>>>                 SortOrder so = getFilter().getSortOrder();
>>>                 if(so == SortOrder.ASC){
>>>                     return SortOrderEnum.ASCENDING;
>>>                 }
>>>                 else{
>>>                     return SortOrderEnum.DESCENDING;
>>>                 }
>>>             }
>>>         };
>>>     }
>>>
>>>
>>>
>>>
>>>
>>>     public String execute(){
>>>         return SUCCESS;
>>>     }
>>>
>>>
>>>
>>>
>>>     public SituacaoMaterialServico getFilterSituacao() {
>>>         return filterSituacao;
>>>     }
>>>
>>>     public void setFilterSituacao(SituacaoMaterialServico filterSituacao) {
>>>         this.filterSituacao = filterSituacao;
>>>     }
>>>
>>>
>>>
>>>
>>>     @Override @SuppressWarnings("unchecked")
>>>     public Map getSituacoes() {
>>>         Map situacoes =  super.getSituacoes();
>>>         situacoes.put("", "Todos");
>>>         return situacoes;
>>>     }
>>>
>>>
>>> }
>>>
>>>
>>>
>>> my struts.xml :
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE struts PUBLIC
>>>     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>     "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>
>>>
>>> <struts>
>>>     <constant name="struts.objectFactory" value="spring" />
>>>     <package name="sicat2-default" extends="struts-default"
>>> abstract="true">
>>>         <interceptors>
>>>             <interceptor name="annotationRoles"
>>> class="br.com.cesan.sicat2.interceptor.AnnotationRolesInterceptor" />
>>>             <interceptor-stack name="defaultStack">
>>>                 <interceptor-ref name="annotationRoles" />
>>>                 <interceptor-ref name="exception" />
>>>                 <interceptor-ref name="alias" />
>>>                 <interceptor-ref name="servletConfig" />
>>>                 <interceptor-ref name="timer" />
>>>                 <interceptor-ref name="prepare" />
>>>                 <interceptor-ref name="i18n" />
>>>                 <interceptor-ref name="chain" />
>>>                 <interceptor-ref name="modelDriven" />
>>>                 <interceptor-ref name="debugging" />
>>>                 <interceptor-ref name="fileUpload" />
>>>                 <interceptor-ref name="checkbox" />
>>>                 <interceptor-ref name="staticParams" />
>>>                 <interceptor-ref name="params">
>>>                   <param name="excludeParams">dojo\..*</param>
>>>                 </interceptor-ref>
>>>                 <interceptor-ref name="conversionError" />
>>>             </interceptor-stack>
>>>         </interceptors>
>>>     </package>
>>>
>>>     <package name="sicat2-ui" extends="sicat2-default" >
>>>         <interceptors>
>>>             <interceptor name="ui"
>>> class="br.com.cesan.sicat2.struts2.UIActionInterceptor" />
>>>             <interceptor-stack name="uiStack">
>>>                 <interceptor-ref name="defaultStack" />
>>>                 <interceptor-ref name="store" />
>>>                 <interceptor-ref name="ui" />
>>>                 <interceptor-ref name="validation">
>>>                     <param
>>> name="excludeMethods">setup,input,back,cancel,browse,execute</param>
>>>                 </interceptor-ref>
>>>                 <interceptor-ref name="workflow">
>>>                     <param
>>> name="excludeMethods">setup,input,back,cancel,browse,execute</param>
>>>                 </interceptor-ref>
>>>             </interceptor-stack>
>>>         </interceptors>
>>>         <default-interceptor-ref name="uiStack"  />
>>>     </package>
>>>     <package name="servico" extends="sicat2-ui" namespace="/servico">
>>>         <action name="MaterialServicoList!*" method="{1}"
>>> class="br.com.cesan.sicat2.module.servico.MaterialServicoList">
>>>
>>> <result>/WEB-INF/jsp/module/servico/MaterialServicoList.jsp</result>
>>>         </action>
>>>         <action name="MaterialServicoAdd!*" method="{1}"
>>> class="br.com.cesan.sicat2.module.servico.MaterialServicoAdd">
>>>             <param name=""></param>
>>>             <result
>>> name="input">/WEB-INF/jsp/module/servico/MaterialServicoAdd.jsp</result>
>>>             <result name="success" type="redirectAction">
>>>                 <param name="actionName">MaterialServicoList</param>
>>>                 <param name="operationMode">RETRIEVE</param>
>>>             </result>
>>>         </action>
>>>         <action name="MaterialServicoEdit!*" method="{1}"
>>> class="br.com.cesan.sicat2.module.servico.MaterialServicoEdit">
>>>             <result
>>> name="input">/WEB-INF/jsp/module/servico/MaterialServicoEdit.jsp</result>
>>>             <result name="success"
>>> type="chain">MaterialServicoList</result>
>>>         </action>
>>>     </package>
>>> </struts>
>>>
>>>
>>> what else i need to show to help?
>>>
>>>
>>> On Thu, Dec 4, 2008 at 1:57 PM, Dave Newton <newton.dave@yahoo.com> wrote:
>>>
>>>> --- On Thu, 12/4/08, Eugenio Perrotta Neto wrote:
>>>> > i know that. but it just happen when i use tiles or a Tag
>>>> > file. if a use a plain JSP it does not happen
>>>> >
>>>> You'll probably have to supply some example
>>>> configuraton/pages/definitions/etc. that duplicate the problem for us to
>>>> help; I'm using Tiles in an S2 app and don't see this behavior (as far as
I
>>>> know, anyway).
>>>>
>>>> Dave
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>> --
>>> Eugenio Perrotta Neto
>>> Tel: (27) 9913-8080
>>>
>>
>>
>>
>> --
>> Eugenio Perrotta Neto
>> Tel: (27) 9913-8080
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Mime
View raw message