Announcement Announcement Module
Collapse
No announcement yet.
Can we do this? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can we do this?

    Hi,

    I have a bean "Student" which contains a getter method getClass() which returns an instance of a "Class". In the JSP i need to bind the attributes in returned Class to HTML text fields... How can I do a <spring:bind> to the Class instance returned by getClass() method in JSP.

    let's say the text field is:

    <input type="text" name="classType">

    I need to bind the above field with the returned "Class" instance

    <spring:bind path="student.getClass().classType"> ???
    <input type="text" name="classType">
    </spring:bind>

    The above does not works...what is the right syntax?

    An example will be appreciated.

    Thx!
    A

  • #2
    I'm surprised that even compiles. getClass() is defined in java.lang.Object as final:-

    Code:
    public final native Class getClass();
    And there is no such thing as a classType in the java.lang.Class object.

    Rule number one, do not name your classes with the same name as anything in java.lang, and if possible do not name them the same as anything in the Java API.

    So, say that you've changed your class to be StudentClass and the getter method in Student is getStudentClass(), your bind code would be:-

    Code:
    <spring:bind path="student.studentClass.classType">
        <input type="text" name="classType">
    </spring:bind>
    Bob

    Comment


    • #3
      Thanks man.... that was an example which I composed as my scenario would require a more complex description.. thx for poiting out the mistake ;-)

      will check out the same..

      A

      Comment


      • #4
        Why are you binding on the class?

        Anyways, should you still decide you need to do this you would want:

        Code:
        <spring:bind path="student.class.classType"> ???
          <input type="text" name="classType">
        </spring:bind>
        And you will need to register a property editor for ClassType.

        Comment

        Working...
        X