Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Struts <html:errors/>

Posted on 2004-04-19
8
11,831 Views
Last Modified: 2007-12-19
Hi

I'm trying to use the <html:errors/> tag.

- I have a page where I have put the tag.

<html:errors/>

- In struts-config.xml I have defined the resource bundle for the error messages.

<message-resources parameter="tm-struts-messages" null="false"></message-resources>

- In the Struts action I add the error to the request with the following code.

errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("field.empty"));

if (errors.size() > 0) {
saveErrors(request, errors);
}

- The resource bundle contains the key "field.empty".

- But the problem is that on the page I get the following error message (not the text in the resource bundle):

???en_US.field.empty???

<b>What's the problem?</b>
0
Comment
Question by:mbutu
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 10857874
Try adding in web.xml -- inside the

  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

bit,

    <init-param>
      <param-name>application</param-name>
      <param-value>tm-struts-messages</param-value>
    </init-param>

and changing:

<message-resources parameter="tm-struts-messages" null="false"></message-resources>

to

<message-resources parameter="resources.application"/>

This is the way I've got mine set up, and it seems to work fine :-)

Hope this helps :-)

Tim
0
 

Author Comment

by:mbutu
ID: 10858730
Tried it but it did not help.
0
 
LVL 1

Expert Comment

by:KartikShah
ID: 10861072
Hi,

If you are using Struts 1.1, you will need to change the following line

------
<message-resources parameter="tm-struts-messages" null="false"></message-resources>
------

Try to place the resource file under the classes folder, and reference it like a class name as one does it in ResourceBundle class.

E.g.You have placed the file tm-struts-messages.properties in ... WEB-INF/classes/com/temp/resources

then the tage should be like

------
<message-resources parameter="com.temp.resources.tm-struts-messages"></message-resources>
------

Hope this helps

Kartik
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:mbutu
ID: 10866609
Hi

I've checked and the file is in the /WEB-INF/classes folder.
It's not inside a package so therefore I don't put the package name in front of the file name.

Mbutu

0
 
LVL 2

Accepted Solution

by:
_marko_ earned 500 total points
ID: 10918151
Hi mbutulito ;)

I once had a similar problem. I had three languages: English, Finnish and Swedish in the following files:

ApplicationResources.properties <-- english
ApplicationResources_fi.properties <-- finnish
ApplicationResources_se.properties <-- swedish

I had to change ApplicationResources.properties into ApplicationResources_en.properties in order to get everything going my way. Since your app complains of "en_US" you might want to rename "tm-struts-messages.properties" into "tm-struts-messages_en_US.properties".

I'm not this is the problem in your case but it's definately worth a shot.


Regards,

Marko
0
 

Author Comment

by:mbutu
ID: 10920576
You are fantastic _marko_ I've never met a Struts expert like you. Thank you so much. Now I won't get fired from the project. Can I send you a small gift. I'm considering a couple of hundred dollars as a gift to you _marko_. For saving me and my family. Do you accept PayPal.

Yours truly
Mbutu and family
0
 
LVL 2

Expert Comment

by:_marko_
ID: 10920619
Hahaha :) You're welcome.



(I know mbutu IRL, he's being sarcastic)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10926440
:-D
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question