Uploaded image for project: 'Click'
  1. Click
  2. CLK-68

Add getPagePath() method to Context class



    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • core
    • None



      When I use Strings in Java code I always have the feeling to doublecheck -
      especially when the right value of the String is not defined by the class
      itself. As is the case for Page.setRedirect() and for direct links or AJAX

      So it would make it easier if the following method were added:

      • Looks up the absolute resource path for the given Page class.
      • <at> throws IllegalArgumentException if no unique mapping between Page class
        and path
        String Context.getPagePath(Class pageClass) throws IllegalArgEx if no
        unique mapping

      'type-safety is only a side-effect. The main reason is that the correct
      value of a link or redirect String is defined in click.xml and not in the
      Page and therefore object encapsulation is broken, which decreases
      maintainability and separation of concerns dramatically. In concept it is
      simalr to Struts global-forward configs only without the extra

      The same effect can be already achieved by
      Context.createPage(pageClass).getPath() but this is comparable very
      inefficient (creating the Page and a Format object) and there are already
      many convinience methods in Context.

      On top of this a PageLink Control can be implemented, which is similar to
      ActionLink but points directly to the target Page and thus avoids the
      extra hop over the originating Page and makes using relative resource
      links easier.

      Implementation wise it is easy to add and with no side-effects to current
      code. The Context.getPagePath(Class) method will directly delegate to
      ClickServlet.PageFactory.getPagePath(Class) which itself does directly
      delegate to ClickApp. Context.getPagePath(Class) will do additional the
      null check and in case throw an IllegalArgumentException.




            medgar Malcolm Edgar
            click_christian Christian Essl
            0 Vote for this issue
            0 Start watching this issue