Thanks, but I've seen that. It's not what I've been trying to do.
Rather than overriding the message I simply want my application to
read Errors.properties just like tapestry does it.

On 7/11/07, Donyee <[EMAIL PROTECTED]> wrote:
You can find it here!
http://wiki.apache.org/tapestry/Tapestry5HowToOverrideTheDefaultErrorMessageBanner

2007/7/11, Adam Zimowski <[EMAIL PROTECTED]>:
> Okay, I still don't know a "Tap5" way of doing this, so this works,
> although that's an ugly hack:
>
> Template:
>
> <t:errors banner="banner"/>
>
> Page Class:
>
> public String getBanner() {
>         if(_unknownError) {
>                 return "Unknown Error";
>         }
>         else {
>                 return getDefaultBanner();
>         }
> }
>
> private String getDefaultBanner() {
>         try {
>                 Properties props = new Properties();
>                 InputStream in =
> 
getClass().getResourceAsStream("/org/apache/tapestry/corelib/components/Errors.properties");
>                 props.load(in);
>                 String banner = props.getProperty("default-banner");
>                 in.close();
>                 return banner;
>         }
>         catch(Exception e) {
>                 return e.getMessage();
>         }
> }
>
> However, wouldn't this be much simpler? (It doesn't work though).
>
> @Inject
> @Path("classpath:org/apache/tapestry/corelib/components/Errors.properties")
> private Messages _errorMessages;
>
> public String getBanner() {
>         if(_unknownError) {
>                 return "Unknown Error";
>         }
>         else {
>                 return _errorMessages.get("default-banner");
>         }
> }
>
> I know that documentation for @Path annotation states it can only be
> used in conjunction with Assets. But wouldn't this be a good case as
> well? What am I missing?
>
> On 7/9/07, Adam Zimowski <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > In my page class I'd like to retrieve the original value for
> > default-banner ("You must correct the following errors before you may
> > continue.") which is stored in Errors.properties in tapestry-core.jar.
> > I'd like to have this String accessible to my page class as a
> > property. Is there a field annotation for this or should I just use
> > standard property file read mechanism to get at that?
> >
> > Thanks
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
----徐 依伟

Reply via email to