You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Barry L. Kline" <bl...@attglobal.net> on 2011/02/14 16:30:55 UTC

Interceptor or preparable/ModelDriven or ActionChain ?

I have an application used to track response times.  Essentially, an
event occurs and a database row is created with a Timestamp showing when
it occurred.  A "trouble sheet" is printed and the technicians take care
of the problem, filling in the sheet.

Once the sheet migrates back to the office the secretaries enter the
data on the sheet into a Struts2 web application.

The sheet is date-heavy, with fields such as:

1) time tech received the call
2) time the problem was resolved
3) time the tech got back to the office.

My application works fine, except that the Timestamp fields are rendered
as, well, ugly Timestamp fields which require the secretaries to follow
a specific format for data entry.

Some of our techs use 24-hour time format, some use 12-hour and in any
event the data entry is long.  I have written a DateFormatter class that
can be used to identify which format the secretary used and also to
allow them to enter only the times, using the date from the original
Timestamp as a reference.

My problem is how to get the Timestamp fields formatted properly before
display and then how to process the data that was entered to update the
Timestamp field in the database.

I'm guessing that I'll have to use String fields instead of Timestamp so
that I can control the formats and values in the .jsp.

My question concerns how to actually do this.   I've googled and have
the "Struts 2 Design and Programming" book and from what I can see, my
options look to be:

1) Use an interceptor both before and after to do the formatting.
2) Use the ModelDriven / Preparable interfaces to do the deed

or because I need to get data from a database prior to a display:

3) use Action chaining, getting the data first in one Action, then
chaining to another (armed with an interceptor) to do the formatting
both ways.

My questions are then:  "Which would be the most elegant means to this
end?" and "Can someone point me to example code?"

Thanks very much in advance.

Barry




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Interceptor or preparable/ModelDriven or ActionChain ?

Posted by "Barry L. Kline" <bl...@attglobal.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/14/2011 11:33 AM, Paweł Wielgus wrote:
> Hi Barry,
> maybe custom converter will suits your needs?
> 
> http://struts.apache.org/2.2.1.1/docs/type-conversion.html
> 
> Best greetings,
> Paweł Wielgus.

Thank you very, very much!

That looks like it might be the ticket.

Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFNWXmbCFu3bIiwtTARAiZ1AJ4tR6Ufjt//NFYdGbq0Cok+xw3hywCdFAnl
JowaSGIlaANOjIWsGJKP8e4=
=p4TE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Interceptor or preparable/ModelDriven or ActionChain ?

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Barry,
maybe custom converter will suits your needs?

http://struts.apache.org/2.2.1.1/docs/type-conversion.html

Best greetings,
Paweł Wielgus.


2011/2/14 Barry L. Kline <bl...@attglobal.net>:
> I have an application used to track response times.  Essentially, an
> event occurs and a database row is created with a Timestamp showing when
> it occurred.  A "trouble sheet" is printed and the technicians take care
> of the problem, filling in the sheet.
>
> Once the sheet migrates back to the office the secretaries enter the
> data on the sheet into a Struts2 web application.
>
> The sheet is date-heavy, with fields such as:
>
> 1) time tech received the call
> 2) time the problem was resolved
> 3) time the tech got back to the office.
>
> My application works fine, except that the Timestamp fields are rendered
> as, well, ugly Timestamp fields which require the secretaries to follow
> a specific format for data entry.
>
> Some of our techs use 24-hour time format, some use 12-hour and in any
> event the data entry is long.  I have written a DateFormatter class that
> can be used to identify which format the secretary used and also to
> allow them to enter only the times, using the date from the original
> Timestamp as a reference.
>
> My problem is how to get the Timestamp fields formatted properly before
> display and then how to process the data that was entered to update the
> Timestamp field in the database.
>
> I'm guessing that I'll have to use String fields instead of Timestamp so
> that I can control the formats and values in the .jsp.
>
> My question concerns how to actually do this.   I've googled and have
> the "Struts 2 Design and Programming" book and from what I can see, my
> options look to be:
>
> 1) Use an interceptor both before and after to do the formatting.
> 2) Use the ModelDriven / Preparable interfaces to do the deed
>
> or because I need to get data from a database prior to a display:
>
> 3) use Action chaining, getting the data first in one Action, then
> chaining to another (armed with an interceptor) to do the formatting
> both ways.
>
> My questions are then:  "Which would be the most elegant means to this
> end?" and "Can someone point me to example code?"
>
> Thanks very much in advance.
>
> Barry
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org