struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: Is it Possible!
Date Wed, 16 Nov 2005 14:39:19 GMT
yes ..Also keep in mind that the convention in locale specific 
implementations is to use
ApplicationResources_<language>_<country>.properties
(where language is optional) and
country is mandatory when there is more than one 
ApplicationResources_*.properties
So In the US it would be ApplicationResources_en_us.properties

http://www.allapplabs.com/struts/struts_internationalization.htm
but Struts uses the message-resources tag to ascertain the location of the 
ApplicationResources file e.g.
<message-resources parameter="fubar.ApplicationResources">
would be located in /WEB-INF/classes/fubar/ApplicationResources.properties
Then pull in the struts-bean which will reference the country specific 
ApplicationResources_*.properties file in your web.xml
      <taglib>
        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
      <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>


Now we are ready to reference the ApplicationResources_*.properties thru the 
bean
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
      <html>
      <head>
      <title>Sample Struts Application</title>
      </head>
      <body>
        <html:form action="Name" name="nameForm" type="fubar.NameForm">
          <table width="80%" border="0">
            <tr>
              <td><bean:message key="app.name" />:</td>

      The Spanish ApplicationResources_es.properties file.
      app.name=Nombre
      app.hello=Hola

      The English ApplicationResources.properties file.
      app.name=Name
      app.hello=Hello


and of course app.name is an key entry in each of your 
ApplicationResources_*.properties file

I am sure you agree this is fun stuff,
HTH,
Martin-
----- Original Message ----- 
From: "Vishal Dalal" <vishal.dalal@ideacellular.com>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Tuesday, November 15, 2005 11:54 PM
Subject: RE: Is it Possible!



try using (className.class).getResource("NameOfResourceInFolder");
it returns a URL
get path from String path = URLName.getPath();
and then,
add your relative path to the path returned

-----Original Message-----
From: Shailesh Barde [mailto:shailjava@rediffmail.com]
Sent: Wednesday, November 16, 2005 9:51 AM
To: user@struts.apache.org
Subject: Is it Possible!



hi,
I want to access myMessegeResources.properties.However, if i try to access
it this way it throws an exception of FileNotFound.However if i give Disk
absolute path then it accesses that myMessegeResources.properties file.
  How to access the relative file in WEB-INF

1)Doesn't Works:-Here i have tried various relative paths to WEB-INF but not
worked!

public class showFilevalues {
public static void main(String args[])throws Exception
    {
      FileReader fr=new FileReader
("/WEB-INF/classes/myMessegeResources.properties");
      BufferedReader br=new BufferedReader(fr);
      String s;
      while((s=br.readLine())!= null){
      System.out.println(s);        }
    fr.close();
      }
}



This Works:-
public class showFilevalues {
public static void main(String args[])throws Exception
    {
      FileReader fr=new FileReader
("C:/eclipse/workspace/shail/myProjectcontext/WEB-INF/classes/myMessegeResou
rces.properties");
      BufferedReader br=new BufferedReader(fr);
      String s;
      while((s=br.readLine())!= null){
      System.out.println(s);        }
    fr.close();
      }
}
  Is it Possible to how to access the relative file?

Regards,
Shailesh

Make your callers hear anything you like.Call 456 say DIALER TONES.

An idea can change your life.

************** LEGAL DISCLAIMER ************
This E-Mail may contain Confidential and/or legally privileged Information 
and is meant for the intended recipient(s) only. If you have received this 
e-mail in error and are not the intended recipient/s, kindly notify us at 
mailadmin@ideacellular.com and then delete this e-mail immediately from your 
system. You are also hereby notified that any use, any form of reproduction, 
dissemination, copying, disclosure, modification, distribution and/or 
publication of this e-mail, its contents or its attachment/s other than by 
its intended recipient/s is strictly prohibited and may be unlawful.

Internet Communications cannot be guaranteed to be secure or error-free as 
information could be delayed, intercepted, corrupted, lost, or contain 
viruses. IDEA Cellular Limited does not accept any liability for any errors, 
omissions, viruses or computer problems experienced by any recipient as a 
result of this e-mail.

---------------------------------------------------------------------
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


Mime
View raw message