Announcement Announcement Module
Collapse
No announcement yet.
addRequiredParameter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • addRequiredParameter

    Both GenericFilterBean and HttpServletBean have a method named addRequiredProperty(String). Their javadoc reads:

    Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter.
    Subclasses can invoke this method when and where? I am assuming a subclass must do it in init like this:

    Code:
    public void init(..) {
        addRequiredProperty("foo");
        addRequiredProperty("bar");
        super.init(..);
    }
    Anywhere else would be too late, and if super.init is not called, none of the parameters will be set into the properties at all. Is this right?

    Whatever the case, the javadocs should be more explicit as to when addRequiredProperty must be called, to avoid confusion with any of the other init* methods.

  • #2
    Init is
    public final
    so a subclass can't actually overwrite it. Only a subclass constructor can reasonably call this method.

    Comment


    • #3
      Duly noted.

      I suggest changing:

      It is also possible for subclasses to specify required properties.
      To:

      It is also possible for subclasses to specify required properties through {@link #addRequiredProperty(String) addRequiredProperty} calls in the constructor.

      Comment


      • #4
        I added something relatively similar, a couple of days ago...

        Comment


        • #5
          Hi,

          Are there any way to set the required properties through the application context?

          Something as:

          <property name="requiredProperty">
          <set>
          <value>foo</value>
          </set>
          </property>

          Regards.

          Comment


          • #6
            You can use FilterToBeanProxy from the Acegi Security System. Some variant of this will probably make its way into Spring for v1.2...

            Comment

            Working...
            X