Portlet instance Admin
vishalstudent123 Aug 18, 2008 6:16 AMHi,
I'm trying to implement the admin preferences. Where the admin can change default values for a portlet instance that will be reflected for everyone viewing that page. Allowing administrators to easily tweak values such as the number of images to display in each column/row for a category portlet for example. This can be done in the admin portlet, but it can be difficult for non-programmers to understand how instances are configured and which instance is displayed on which page. Which is why I also want a admin GUI layout for portlets.
I have seen the thread: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=139028 but i also saw this in the API of 2.6.3:
There are two different types of preferences:
modifiable preferences - these preferences can be changed by the portlet in any standard portlet mode (EDIT, HELP, VIEW). Per default every preference is modifiable.
read-only preferences - these preferences cannot be changed by the portlet in any standard portlet mode, but may be changed by administrative modes. Preferences are read-only, if the are defined in the deployment descriptor with read-only set to true, or if the portlet container restricts write access.
So i went about making preferences read-only and set up a custom view:
<portlet> ..... <preference> <name>numberOfImages</name> <value>5</value> <read-only>true</read-only> </preference> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> <portlet-mode>Admin</portlet-mode> </supports> </portlet> <custom-portlet-mode> <name>Admin</name> </custom-portlet-mode> </portlet-app>
allowed my "admin" to edit instance preferences:
<instance> <instance-id>name</instance-id> <portlet-ref>name</portlet-ref> <security-constraint> <policy-permission> <action-name>admin</action-name> <role-name>Admin</role-name> </policy-permission> <policy-permission> <action-name>view</action-name> <unchecked/> </policy-permission> </security-constraint> </instance>
But when trying to write to the value i get a error:
javax.portlet.ReadOnlyException: Key foo cannot be written
Also when i am looking at the admin portlet logged in as admin i cannot click on the value for a portlet varible where i can change it. Other preferences in other portlets not mark as "read-only" can be changed.
It's like the admin cannot write to the values. Is there something i am missing? I'm using the same default admin that was set when i downloaded it.
Is there something i need to for admin to write to read only values ?