Announcement Announcement Module
Collapse
No announcement yet.
What is the best way to display a string result of a static pojo method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is the best way to display a string result of a static pojo method

    I have a page index.jspx in a web mvc application

    Code:
    <!-- selects a static view for rendering without the need for an explicit controller -->
    <mvc:view-controller path="/" view-name="index"/>
    I have a static method on an entity class that returns a string.

    In screens where I use a custom controller I use

    Code:
    @ModelAttribute("currentZone")
    public String getCurrentZone(){
    	return ZoneElement.getCurrentZone();
    }
    
    and
    
    ${currentZone} in the page to display the value
    What is the best way to display this same static method result in the index.jspx?

    I want to avoid creating a controller just for this one little bit of data, or a custom tag for that matter, but I suppose if that's the best way, so be it. I am probably over thinking this.

  • #2
    Create a HandlerInterceptor which adds this to the model, saves you also adding this method to all controllers. That way the property is always present.

    Comment


    • #3
      Excellent, and in that Interceptor I can branch so only those pages that need this attribute will make the call. Thanks.

      Comment

      Working...
      X