struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Márcio Gurgel" <marcio....@gmail.com>
Subject Re: Struts 2 + Hibernate question
Date Fri, 30 May 2008 04:10:02 GMT
Sure, the updated values are not displayed in <s:property />. But the data
is not erased, all updated values are ok at my database, it just doesnt
appear at my jsp. Seems that the database content was disregard.
My findById method returns a old object /:

If you need I can translate the code.
I'm already so thankfull !



2008/5/30 dusty <dustin_pearce@yahoo.com>:

>
> hmmm....I am having trouble with the non-english code.  ;-)
>
> Lets try this another way.  When you say old, what do you mean.  The new
> values that saved for the object are not displaying in <s:property .../>
> tags?  The relationships are missing?  Data is erased?
>
> -D
>
>
>
> Márcio Gurgel wrote:
> >
> > Hi!
> >
> > The result is a redirect.
> > Thanks a lot for your attention.
> >
> > Follow the codes:
> >
> > *** STRUTS.XML *** Redirect
> > <action name="alterarFsc" method="alterarFsc"
> > class="br.com.sgvdba.actions.cliente.ClienteAction">
> >                 <result name="success" type="redirectAction">
> >                     ${clienteFsc.cd}
> >                     abrirPageFsc
> >                     /cliente
> >                 </result>
> >                 <result type="tiles"
> > name="input">default.clienteFsc</result>
> >             </action>
> >
> > *** ACTION - UPDATE ***
> > public String alterarFsc(){
> >         try {
> >             String[] telefones = new String[]{telefone1, telefone2,
> > telefone3, telefone4};
> >             Integer[] cdsTipTel = new Integer[]{cdTipoTelefone1,
> > cdTipoTelefone2, cdTipoTelefone3, cdTipoTelefone4};
> >             getClienteFacade().alterarFsc(clienteFsc, getUsuarioLogado(),
> > cdSitCliente, telefones, cdsTipTel, cdCidadeKey);
> >             cdClienteFsc = clienteFsc.getCd();
> >         } catch (Exception e) {
> >             addActionError(SgvdbaConstants.ERRO_DEFAULT +
> e.getMessage());
> >             return Action.INPUT;
> >         }
> >         return Action.SUCCESS;
> >     }
> >
> > *** STRUTS.XML - REDIRECTED ACTION ***
> > <action name="abrirPageFsc" method="abrirPageFsc"
> > class="br.com.sgvdba.actions.cliente.ClienteAction">
> >                 <result type="tiles"
> > name="success">default.clienteFsc</result>
> >                 <result type="tiles"
> > name="input">default.clienteFsc</result>
> >             </action>
> >
> > *** ACTION - A OPEN DATA METHOD ***
> >     public String abrirPageFsc(){
> >         try {
> >             if (clienteFsc != null){
> >                 if (clienteFsc.getCd() != null){
> >
> >
> >                     // ------> Here's comming the old object
> >                     clienteFsc =
> > getClienteFacade().recuperarFscPorId(clienteFsc.getCd());
> >
> >
> >
> > clienteFsc.setCep(MaskUtil.maskCep(clienteFsc.getCep()));
> >
> > clienteFsc.setCpf(MaskUtil.maskCpf(clienteFsc.getCpf()));
> >                     setQtdTelefones(clienteFsc.getTelefones().size());
> >
> >                     int i = 0;
> >                     List<Telefone> telefoneList =
> > getTelefoneFacade().recuperarPorCliente(clienteFsc.getCd());
> >                     for (Iterator<Telefone> it = telefoneList.iterator();
> > it.hasNext();){
> >                         Telefone telefone = (Telefone) it.next();
> >                         switch (i) {
> >                         case 0:
> >                             telefone1 =
> > MaskUtil.maskTelefone(telefone.getNumTel());
> >                             valueTipoTelefone1 =
> > telefone.getTipoTelefone().getCd();
> >                             break;
> >                         case 1:
> >                             telefone2 =
> > MaskUtil.maskTelefone(telefone.getNumTel());
> >                             valueTipoTelefone2 =
> > telefone.getTipoTelefone().getCd();
> >                             break;
> >                         case 2:
> >                             telefone3 =
> > MaskUtil.maskTelefone(telefone.getNumTel());
> >                             valueTipoTelefone3 =
> > telefone.getTipoTelefone().getCd();
> >                             break;
> >                         case 3:
> >                             telefone4 =
> > MaskUtil.maskTelefone(telefone.getNumTel());
> >                             valueTipoTelefone4 =
> > telefone.getTipoTelefone().getCd();
> >                             break;
> >                         }
> >                         i++;
> >                     }
> >                 }
> >
> >             }
> >
> >         } catch (Exception e) {
> >             addActionError(SgvdbaConstants.ERRO_DEFAULT +
> e.getMessage());
> >         }
> >         return Action.SUCCESS;
> >     }
> >
> >
> >
> > 2008/5/30 dusty <dustin_pearce@yahoo.com>:
> >
> >>
> >> What is the result of the post action?  A redirect?  JSP?
> >>
> >> Its probably best to post some of the relevant action code and
> struts.xml
> >> first, and then if we need to we can go into the Hibernate code.
> >>
> >> -D
> >>
> >> Márcio Gurgel wrote:
> >> >
> >> > Hi all!
> >> >
> >> > I'm using struts 2 + hibernate.
> >> > I've a strange problem, if someone could give me a hand I'll be so
> >> > tankfull.
> >> >
> >> > If I persist a object in my app every things go well and all
> >> relationchips
> >> > are stored correctey correctly.
> >> > The problem occours when I update this object... After the update all
> >> data
> >> > are stored correctly too, but the problem is that my page shows the
> old
> >> > object (different from database).
> >> >
> >> > This could be some kind of cash from struts 2? Or my problem is just
> >> > hibernate?
> >> >
> >> > I tryed this methods to force a refresh after bring the object from
> >> > database
> >> > session.refresh(obj)
> >> > session.flush()
> >> >
> >> > Tank so much for attention!
> >> >
> >> > Márcio Gurgel
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Struts-2-%2B-Hibernate-question-tp17527841p17550934.html
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Struts-2-%2B-Hibernate-question-tp17527841p17551202.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message