Hi,
I got some questions about the portlet preferences...
The following two methods should return the provided default value
if no value is bound to the given preference key:
PortletPreferences#getValue(String key, String def)
PortletPreferences#getValues(String key, String[] def)
While the following two methods set value (null is allowed!!) of a preference:
PortletPreferences#setValue(String key, String value)
PortletPreferences#setValues(String key, String[] values)
Here come the questions......
1/ If in portlet.xml we have:
<preference>
<name>toto</name>
</preference>
What should be returned if we call PortletPreferences.getValue("toto", "hello")?
We should get a null or "hello"?
What should be returned if we call PortletPreferences.getValues("toto", new String[] { "hello" })?
We should get an empty string array (length == 0)? or the default array?
2/ Take a look at the following code:
PortletPreferences prefs = ... // get preferences object
prefs.setValue("titi", null); // null is allowed!
String value = prefs.getValue("titi", "hello");
System.out.println(value);
What should we have on the console? null? hello?
3/ code below:
PortletPreferences prefs = ... // get preferences object
prefs.setValues("titi", new String[] { null, "world" } );
String value = prefs.getValue("titi", "hello");
System.out.println(value);
What should we have on the console? null? hello?
4/ code below:
PortletPreferences prefs = ... // get preferences object
prefs.setValues("titi", new String[0]);
String value = prefs.getValues("titi", new String[] { "hello" });
System.out.println(value.length);
What should we have on the console? 0? 1?
5/ code below:
PortletPreferences prefs = ... // get preferences object
prefs.setValues("titi", null);
String value = prefs.getValues("titi", new String[] { "hello" });
System.out.println(value);
What should we have on the console? null? the default array .toString()?
Sorry for so many questions... But i am really quite confused about that...
I checked the portlet spec as well as the portlet API javadoc, but neither
has explained my questions clearly.
Thanks in advance!
Regards.
--
ZHENG Zhong
- http://heavyz.blogspot.com/
- http://people.apache.org/~zheng/
- [Portlet Spec.] Portlet preferences questions Zhong ZHENG
- Re: [Portlet Spec.] Portlet preferences questions Patrick Huber
- Re: [Portlet Spec.] Portlet preferences questions Zhong ZHENG
- Re: [Portlet Spec.] Portlet preferences questio... Patrick Huber
- Re: [Portlet Spec.] Portlet preferences que... Stefan Hepper
