View Poll Results: PropertyEditors *should* be called for rendering jsps

Voters
4. You may not vote on this poll
  • Yep

    3 75.00%
  • Nope

    1 25.00%
Results 1 to 7 of 7

Thread: PropertyEditors arent' called when *rendering* jsps.

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    1,905

    Default PropertyEditors arent' called when *rendering* jsps.

    Hi all,

    When I register a propertyEditor, it is only ever called when binding, i.e. when converting request parameters to Objects. It never seems to be called when rendering the jsp.

    This is as I would expect because it gives me the most flexibility. Pain for dates because you have to have the formatting in two places.

    Anyways, a couple of other posters seem to think that property editors *are* called when rendering jsps.

    Can someone from the spring team please put my mind at ease before I go insane and question reality Are propertyEditors called when *rendering* jsps.

    Ta.

    Col

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    OK, seems I *have* been a bit of a plonker

    It appears getAsText *is* called when rendering when used within spring:bind . I think I got horribly confused because property editors are only called within spring:bind tags, not just in "normal" jstl.

    Doh!

    Apologies to all posters that had to put up with me ranting that propertyEditors were *not* called on rendering

  3. #3
    Join Date
    Oct 2005
    Posts
    13

    Default

    Yatesco,

    i'm desperatly trying to have some propertyEditor called when rendering when used within spring:bind. how did you register your propertyEditor (i tried to simply register it to the binder object in overriding method of initBinder of SimlpeFormController, but with no success)?

    thanks,
    Mati.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Try overriding

    Code:
    SimpleFormController.initBinder(HttpServletRequest request,
                              ServletRequestDataBinder binder);
    actually the method is in BaseCommandController but I assume you are using SFC

    You will basically want to call one of the
    Code:
    registerCustomEditor
    methods (check the javadoc for more info.) on the binder.

    HTH

  5. #5
    Join Date
    Oct 2005
    Posts
    13

    Default

    Thanks a lot for your quick reply.
    Actually i had already done exactly what you are suggesting (see my previous post).
    Maybe i'll be more specific - i have a map(representing the application configuration parameters) whose keys type is of my own enum type. The map values are just of type object. I want to have a form representing this map.
    As for my form command object, i'm using some MapCommand object that holds the original map
    Code:
    public class MapCommand {
    
        private Map map;
    
        public void setMap(Map map) {
            this.map = map;
        }
    
        public Map getMap() {
            return this.map;
        }
    }
    The map keys are of type ConfigParam -
    Code:
    public enum ConfigParameter {
    
        activeAlertsExpirationDays(7);
    
        private Object defaultValue;
    
        private ConfigParameter(Object defaultValue) {
            this.defaultValue = defaultValue;
        }
        public Object getDefaultValue() {
            return defaultValue;
        }
    in my jsp form i want to use something like this...
    Code:
    <spring:bind path="command.map['activeAlertsExpirationDays']">
    ...but it doesn't work
    Is there a way to use spring BindTag for binding form fields to map-entries whose keys are not strings?

  6. #6
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Ah, that I am not sure off I imagine you could do something like this, but I am not sure:

    Code:
      <spring:bind path="command.map[${myObj}]">
    but I am just guessing.

    Sorry

  7. #7
    Join Date
    Aug 2005
    Posts
    12

    Default

    Hi yatesco,

    I´m using a MultiActionController... I´ve put a command in the ModelAndView, but I´m having problems with rendering Date´s.. It seems the PropertyEditor is not used at the jsp... Looking the code for the BindTag I´ve noted that a BindStatus only receives a PropertyEditor when there are erros... I´m missing something???

    Thank you so much!
    Eduardo Rodrigues
    Belo Horizonte - MG - Brazil

Similar Threads

  1. handleInvalidSubmit called, why?
    By sulam in forum Web
    Replies: 9
    Last Post: Feb 2nd, 2007, 03:11 AM
  2. Replies: 1
    Last Post: Oct 3rd, 2005, 04:19 PM
  3. onSubmit not called
    By christophe in forum Web
    Replies: 4
    Last Post: Jul 29th, 2005, 05:10 PM
  4. Enabling Spring in ugly JSPs
    By jlindwall in forum Web
    Replies: 2
    Last Post: May 31st, 2005, 12:53 PM
  5. indirectly called method not intercepted
    By springtester in forum AOP
    Replies: 1
    Last Post: Sep 1st, 2004, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •