0

I'm developing a simple tag library in order to centralize the creation of form components.

In my custom tag I need to get the value of the backing object mapped field.

Here is how I pass the field name value to my library:

<jsp:directive.attribute name="field" type="java.lang.String" required="true" rtexprvalue="true" description="The field exposed from the form backing object" />

Inside my tag library, using <form:hidden path="${field}.id" /> from spring tag library works, but how can I get same value not using that library? I do not want to have an input type hidden mapped in my form, but only retrieve the value of that field name.

Thanks for any hints.

gipinani
  • 14,038
  • 12
  • 56
  • 85

1 Answers1

1

You can try the spring:eval tag

  <jsp:directive.attribute name="object" type="java.lang.Object" required="true" description="The form backing object" />
  <jsp:directive.attribute name="field" type="java.lang.String" required="true" description="The field name" />

  <spring:eval expression="object[field]" />
wesker317
  • 2,172
  • 1
  • 16
  • 11
  • It don't works.. theValue variable text value is gas.id, not the real id – gipinani Jul 02 '14 at 12:48
  • This should works :) +1 Do you think it is possible without specifying object? – gipinani Jul 02 '14 at 15:08
  • No I don't think its possible whithout specifying the object. Have a look at Spring Roo, it does what you are trying to do : using a tag library to simplify form creation. http://docs.spring.io/spring-roo/reference/html/base-web.html#jsp-views – wesker317 Jul 02 '14 at 15:19
  • Is from roo that I started to modify tag library :) – gipinani Jul 02 '14 at 15:20