PDA

View Full Version : Spring.Web.UI.Page.GetMessage() failed when no current resc


crabo
09-21-2005, 09:43 AM
In fact, I only defined Resource in the default resc file: MainRes.resc; and hadn't create file: MainRes.en-US.resc and MainRes.zh-CN.resc yet.
I would like to add it later;

But, why can't it use the default, when it failed to get in the current culture?

[NoSuchMessageException: No message found under code 'DEL_FAILED' for locale 'zh-CN'.]
Spring.Context.Support.AbstractMessageSource.GetMe ssage(String name, CultureInfo culture) in E:\StoltChem\Spring.Net\Spring.Core\Context\Suppor t\AbstractMessageSource.cs:296
Spring.Context.Support.AbstractApplicationContext. GetMessage(String name, CultureInfo culture) in E:\StoltChem\Spring.Net\Spring.Core\Context\Suppor t\AbstractApplicationContext.cs:1171
Spring.Web.UI.Page.GetMessage(String name) in E:\StoltChem\Spring.Net\Spring.Web\Web\UI\Page.cs: 566
Web.UI.BaseData.UserList.DeleteData(String strID) in e:\stoltchem\web\basedata\userlist.aspx.cs:157
Web.UI.BaseData.UserList.btnDel_ServerClick(Object sender, EventArgs e) in e:\stoltchem\web\basedata\userlist.aspx.cs:210
System.Web.UI.HtmlControls.HtmlButton.OnServerClic k(EventArgs e) +108
System.Web.UI.HtmlControls.HtmlButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277

Aleks Seovic
09-21-2005, 09:52 PM
I am pretty sure this functionality works as it should, as I'm using it both in my test project and in a few real-world applications and never had any problems with it.

Could you please post your message source definition so I can see if there are any differences there?

Thanks,

Aleks

crabo
09-22-2005, 10:48 AM
Default & en-US:
<data name="DEL_SUCCESSED">
<value>Delete Successed!</value>
</data>
<data name="DEL_FAILED">
<value>Delete Failed!</value>
</data>

zh-CN:
<data name="DEL_SUCCESSED">
<value>删除成功!</value>
</data>
<data name="DEL_FAILED">
<value>删除失败!</value>
</data>

If I remove these rows in "zh-CN" resource file. it throw the exception again and again~~~~
no luck to successed!

No message found under code 'DEL_FAILED' for locale 'zh-CN'.
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处 的详细信息。

异常详细信息: Spring.Context.NoSuchMessageException: No message found under code 'DEL_FAILED' for locale 'zh-CN'.

源错误:


行 294: return CodeAsMessage(name);
行 295: }
行 296: throw new NoSuchMessageException(name, culture);
行 297: }
行 298:

Rick Evans
09-25-2005, 12:36 PM
Hi

I can verify that this is a bug.

I replicated the issue described by crabo (http://forum.springframework.net/profile.php?mode=viewprofile&u=164) while banging out the SpringAir reference application. There is no fallback behaviour as one would expect. I created a JIRA issue (http://opensource2.atlassian.com/projects/spring/browse/SPRNET-193) some days back just so that I would remember to investigate this. I will add some comments to said JIRA issue, and include a small sample project that replicates the issue shortly.

Localization support needs to be looked at more generally too, as (I feel) some areas just don't 'do the right thing'... I will post my concerns to the devlist shortly.

Ciao
Rick

Aleks Seovic
10-19-2005, 05:41 AM
Is this still an issue after the changes I made to localization in Spring.Web?

Crabo, can you check if your resources fallback works as expected with Spring.NET Web Preview Release?

Thanks,

Aleks

Aleks Seovic
10-21-2005, 05:03 AM
This was an issue in ResourceSetMessageSource and I just fixed it.

Regards,

Aleks

crabo
10-23-2005, 03:54 AM
Thank you ,Alerk.

I have moved to CVS 2005-10-12 version.

not the preview version. but still have the problem.

I will try it later. because my project is in a urgen state.

Thank you!

Aleks Seovic
10-23-2005, 05:55 AM
You will need the latest code from CVS, as I fixed this problem on Oct 20, 2005, right before I posted previous message.

Everything works fine on my machine now, but Rick reopened the issue saying that the test fails on his machine, so it would be great if you could test it as well and let us know if it's working or not, as well as if you have .NET SP1 installed or not.

Regards,

Aleks

crabo
10-24-2005, 01:20 PM
Thank you, ALL your guys good job!

I'm sure it's ok now.
I'm working on win2003, .Net Framework1.1 without any patch.
I have never update,or installed a patch,but open the system firewall.

I have resourec: GlobalRes.resc;GlobalRes.en-US.resc;GlobalRes.zh-CN.resc.

and now, I remove the GlobalRes.zh-CN.resc from my project.
Recomplied the whole solution.
aha~~~~ the web page show the default resc instead perfectly!!!

Cheers!

crabo
10-27-2005, 04:28 AM
Aleks!

when the resc is lying in private file, not the GLOBAL RESC, it still happens!!

[NoSuchMessageException: No message found under code 'BTN_TENT_PLAN' for locale 'zh-CN'.]
Spring.Context.Support.AbstractMessageSource.GetMe ssage(String name, CultureInfo culture) in E:\StoltChem\Codes\Spring.Net\Spring.Core\Context\ Support\AbstractMessageSource.cs:296
Spring.Context.Support.AbstractApplicationContext. GetMessage(String name, CultureInfo culture) in E:\StoltChem\Codes\Spring.Net\Spring.Core\Context\ Support\AbstractApplicationContext.cs:1231
Spring.Context.Support.AbstractMessageSource.GetMe ssage(String name, CultureInfo culture) in E:\StoltChem\Codes\Spring.Net\Spring.Core\Context\ Support\AbstractMessageSource.cs:290
Spring.Web.UI.Page.GetMessage(String name) in E:\StoltChem\Codes\Spring.Net\Spring.Web\Web\UI\Pa ge.cs:833
ASP.PlaningList_aspx.__RenderForm1(HtmlTextWriter __output, Control parameterContainer) in E:\StoltChem\Codes\Web\Voyage\PlaningList.aspx:7 0
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +27
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output) +260
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
Spring.Web.UI.Page.Render(HtmlTextWriter writer) in E:\StoltChem\Codes\Spring.Net\Spring.Web\Web\UI\Pa ge.cs:338
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +241
System.Web.UI.Page.ProcessRequestMain() +1929


my spring version is CVS-2005-10-24 10:00pm

Aleks Seovic
10-31-2005, 07:32 PM
I tested both local and global message sources extensively, and everything seems to be working fine.

NoSuchMessageException is perfectly valid scenario in certain cases, so let me go through the resource resolution algorithm in detail and hopefully it will help you debug the issue:

1. Page.GetMessage tries to resolve the message using local resource files. Normal fallback rules are applied, which means that if resource is not found in *.zn-CN.resx file (or the file doesn't exist), it will look for it in *.zn.resx and finally in *.aspx.resx.

2. If the resource is still not found, we'll try to resolve it in the context-global message source, that is defined in the config file. Same fallback rules will apply: *.zn-CN.resx -> *.zn.resx -> *.resx

3. If it's not found, we'll look it up in the parent application context's message source, using same fallback rules.

4. Repeat 3 as long as parent application context is not null.

5. If the resource is not found in the root application context's message source, we will check the value of the UseCodeAsDefaultMessage property of the message source (false by default). If it is true, we will return the string in the format '## resourceKey ##', so you can easily notice missing resources in your UI. Otherwise, NoSuchMessageException will be thrown.

Hope this helps, let me know if you can determine the problem. If not, I will need to see a concrete example before I can dig deeper.

Regards,

Aleks

crabo
11-01-2005, 01:10 AM
ya!

I debug it, it's ok now.

sorry!