4 Replies Latest reply on Apr 21, 2008 4:21 PM by Pawel Wrzeszcz

    custom application properties

    Simon Bailey Newbie

      hi,


      in a normal java application, i'd use the

      Properties

      class and put application wide parameters in there. how can i do the same thing in seam? (like setting default upload path for files, or the coordinates of a text field in a pdf template, ...)


      can i put properties in the seam.properties file and access them on demand? if so, how do i get hold of seams properties object?


      or would it be better to use a (stateful, application scope) configuration class with static methods for retrieving data and setting the properties of that class through seam.properties or components.xml?


      regards,
      sb

        • 1. Re: custom application properties
          Pawel Wrzeszcz Novice

          Hi Simon,




          can i put properties in the seam.properties file and access them on demand? if so, how do i get hold of seams properties object?



          You'll find information how to make use of seam.properties file in the Configuring Seam components chapter.


          Cheers,
          -Pawel

          • 2. Re: custom application properties
            Simon Bailey Newbie

            hi pawel,



            Pawel Wrzeszcz wrote on Apr 21, 2008 03:54 PM:


            You'll find information how to make use of seam.properties file in the Configuring Seam components chapter.


            i read that. but it doesn't tell me anywhere how to get hold of the properties i set in there if they're NOT bound to a backing bean.  i'd like to set the upload directory once and use that directory in multiple different beans. if the only way to do this is to create an application scoped sfsb, then so be it. but i don't really want to put the following in my seam.properties:


            org.aspsimon.termcomp.bean1.uploadDir=dir
            org.aspsimon.termcomp.bean2.uploadDir=dir
            org.aspsimon.termcomp.bean3.uploadDir=dir
            org.aspsimon.termcomp.bean4.uploadDir=dir
            ...
            



            after reading section 4.2. in the manual i also can't see a method for setting configuration /strings/ not bound to any component in the components.xml.


            any other ideas?


            thanks,
            sb

            • 3. Re: custom application properties
              Pawel Wrzeszcz Novice

              Simon Bailey wrote on Apr 21, 2008 04:02 PM:


              any other ideas?



              Hm... then there's a solution you've already mentioned - application-scoped Seam Component that stores all properties.


              Alternatively, if you got only one property, you can define uploadDir String component in the components.xml file:
              <factory name="uploadDir" scope="APPLICATION" auto-create="true" value="/tmp/dir"/>.


              -P

              • 4. Re: custom application properties
                Pawel Wrzeszcz Novice

                Simon Bailey wrote on Apr 21, 2008 04:02 PM:


                if the only way to do this is to create an application scoped sfsb, then so be it.


                Why SFSB? It can be plain old JavaBean being a Seam Component.


                -P