7 Replies Latest reply on Aug 8, 2006 5:01 AM by P P

    default portlet preferences

    P P Newbie

      How can I set the default preferences for a porltet instance in that instance? (I mean using Java, not an .xml file)?
      I have seen that the default Management Portlet allows that,
      but I don't know how...

        • 1. Re: default portlet preferences
          Peter Johnson Master

          Why not just hard-code the value in your Java source?

          • 2. Re: default portlet preferences
            P P Newbie

            I want admin to be able to modify it from the portlet itself, but not to influence only his preferences, but also the default preferences.

            • 3. Re: default portlet preferences
              Antoine Herzog Master

              look at the Management Portlet and how it does this ?
              you will find thing that you can reuse for what you want to do in the Edit mode of your portlet...

              look also at the concept of Dynamicity, in the wiki and forum (and the web, as I quit remember Roy Russo has written things on this).
              it is what allow the administrator to modify the portal configuration dinamically...

              The configuration of a portlet is stored in the database of jbp, so the default preference are there to.
              It is were you must change them for what you want to do.

              • 4. Re: default portlet preferences
                P P Newbie

                The Management Portlet isn't written by jboss, so I can't get a look at
                its code.

                I've seen the preferences in the database, but I want to change them
                programmaticaly -- how can I access them from the code?

                • 5. Re: default portlet preferences
                  P P Newbie

                  I think I could do it by getting the reference to the current instance and then by calling getPreferences() I would have had access to management of these preferences (I'm also not sure whether it would affect only current user or the default preferences).
                  But I am experiencing a problem -- I get the reference to the InstanceContainer, but when I try to call getInstance(..), a Hibernate exception saying 'unable to locate current JTA transaction' is thrown.
                  What could I do (I've got no idea about Hibernate).

                  • 6. Re: default portlet preferences
                    Boleslaw Dawidowicz Master

                    It's opensource - all stuff you get in portal you can get from CVS. Nothing is hidden ;)


                    For transaction error - you need to set in your jboss-portlet.xml

                    <portlet>
                     <portlet-name>PortletName</portlet-name>
                     <transaction>
                     <trans-attribute>Required</trans-attribute>
                     </transaction>
                     </portlet>


                    or cover your code with transaction context by your self

                    • 7. Re: default portlet preferences
                      P P Newbie

                      Thanks, that does it.
                      Everything else worked just as I wanted, so the problem is solved.