feature setting values appear as instance setting labels/names

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/19/2012 3:33:12 PM
Gravatar
Total Posts 3

feature setting values appear as instance setting labels/names

I use config and resource files to define settings for my custom features, as described in the "Using The Installation System" topic of the developer documentation.

This works fine for the feature definitions; settings come in with their correct names and values.

However, when I add a feature to a page, the settings of the instance show the settings values as labels/names, along with the correct values. When the values are edited, the labels will have changed with them the next time the settings editor is openend. This happens both on my local development and the production site.

I immediately thought of unescaped, illegal characters in the XML file, but this happens with completely innocuous values such as integer numbers, and my XML file validates in IE.

Any suggestions why this might happen and how to fix it would be greatly appreciated.

Cheers, Hartmut

1/23/2012 1:57:00 PM
Gravatar
Total Posts 18439

Re: feature setting values appear as instance setting labels/names

The only thing I can think of that could cause something like that is if one of your settings is a custom ISettingControl. In that case if you had a missing closing tag on an html element inside that control it might cause very weird rendering like you describe.

Its possible there are other causes I haven't thought of but I've certainly never seen the problem you describe.

Hope that helps,

Joe

3/20/2012 7:30:29 AM
Gravatar
Total Posts 3

Re: feature setting values appear as instance setting labels/names

A follow up...

I traced this issue in the debugger and found a couple of lines in the AddSettingControl(CustomModuleSetting s, Panel groupPanel) method of ModuleSettings.aspx.cs that are causing this:

settingLabel = GetGlobalResourceObject(resourceFile, s.SettingName).ToString();
label.Text = "<label class='settinglabel' >" + settingLabel + "</label>";

This is assigning the setting value from the resource file rather than the setting name to the label's Text property. I changed it as follows and everything is fine:

label.Text = "<label class='settinglabel' >" + s.SettingName + "</label>";

The only question is: why would this not affect every site? The code quoted above is from 2.3.7.9 (MSSQL). I don't have another site using precisely that version of mojoPortal. Colleagues of mine use other versions and have never run into this issue.

Thanks,
Hartmut

 

3/20/2012 8:02:55 AM
Gravatar
Total Posts 18439

Re: feature setting values appear as instance setting labels/names

Hi,

Your solution is not correct becuase it breaks localization. You've just hard coded it to use the s.SettingName but in most features that is a resource key and the actual label comes from a resource file adapted to the language of the site or browser.

I guess the actual problem is that if it doesn't exist in the resource file it is coming back as null, so the correct solution is like this:

settingLabel = GetGlobalResourceObject(resourceFile, s.SettingName).ToString();
if (settingLabel == null) { settingLabel = s.SettingName; }

I've made this change in my copy, it will be in the source code repository in the near future.

Hope that helps,

Joe

3/21/2012 4:41:07 AM
Gravatar
Total Posts 3

Re: feature setting values appear as instance setting labels/names

Thanks for looking into this, Joe. I appreciate it.

I'm clearly missing something about regionalization. The resource file being read by the AddSettingControl method is the one I specify in the custom module's config file. That file contains a KeyValuePair resourceKey, resourceValue for each setting, where the resourceKey equals the SettingName. Accordingly, GetGlobalResourceObject(resourceFile, s.SettingName) does not come back as null (I checked in the debugger) but with the resourceValue and assigns that to the label. For example, a setting named "WmsUrl" appears in the resource file under the key "WmsUrl" with the value "http://62.197.41.154:8080/geoserver/SHINE/wms?service=WMS", and this value is what settingLabel = GetGlobalResourceObject(resourceFile, s.SettingName).ToString(); will retrieve from the resource file and assign to the label.

It was my understanding that regionalization was accomplished by having a language-specific resource file for each language, with language specific values, whereas the keys remained the same. That would not allow for translations of setting names. Your response seems to apply that there is yet another resource containing translations for each feature setting name. I am not aware of any such resource, and the AddSettingControl control only seems to read one resource file.

What am I missing?

Thanks again,
Hartmut

3/21/2012 7:14:24 AM
Gravatar
Total Posts 18439

Re: feature setting values appear as instance setting labels/names

It is working correctly.

Accordingly, GetGlobalResourceObject(resourceFile, s.SettingName) does not come back as null (I checked in the debugger) but with the resourceValue and assigns that to the label.

Yes, that is how it is supposed to work, the value is the translated label s.SettingName is the key not the label itself, the value that comes back from the resource file is the label for the current language (determined by the ui culture of the executing thread)

For example you would have the resource file MyResource.resx which is English, if you want to translate it to French you would create a new resource file named MyResource.fr.resx, then if the thread is executing as French it will get the value from that file assuming the file exists and the key and value exist in the file, otherwise it will fall back to English and get the value from MyResource.resx. so the translations for each language are in different .resx files and which one to use is determined by the thread ui culture.

By default the thread ui culture is determined by the user's language preference in their web browser unless the site is configured to use a specific language.

For example, a setting named "WmsUrl" appears in the resource file under the key "WmsUrl" with the value "http://62.197.41.154:8080/geoserver/SHINE/wms?service=WMS"

That isn't the kind of thing that should be put in a resource file, resource files are for strings used on labels and buttons, not for other things. That seems more like something you would set for the default value of the setting not something used for the label for the setting.

Hope that clears it up for you, it is definitely working correctly, all the setting labels for features included in mojoPortal have been translated into many languages and it works fine.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.