FFL2:FFL2 Main/Web Framework/Fantacy URL Encoding: Difference between revisions

From FFL Wiki
Jump to navigation Jump to search
Created page with 'Any URLs in a Java EE web app should be run through the [http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletResponse.html#encodeURL%28java.lang.String%29 HttpServl…'
 
m typos
 
Line 7: Line 7:
* <tt>seasonStartYear</tt>
* <tt>seasonStartYear</tt>


The <tt>DefaultParameterHelper</tt> class gives default values for these parameters if they are not present.  However, this should only ever be the case for the first page a user hits.  After that every link the user clicks should include these parameters, whether or not they are of relevance for the particular page the user is looking at.  So if, for example, one changes <tt>seasonStartYear</tt> from <tt>2014</tt> to <tt>2013</tt> and clicks around the site, this value should persist and be encoded into every linke.
The <tt>DefaultParameterHelper</tt> class gives default values for these parameters if they are not present.  However, this should only ever be the case for the first page a user hits.  After that every link the user clicks should include these parameters, whether or not they are of relevance for the particular page the user is looking at.  So if, for example, one changes <tt>seasonStartYear</tt> from <tt>2014</tt> to <tt>2013</tt> and clicks around the site, this value should persist and be encoded into every link.


The <tt>FantacyURLEncoder</tt> class is used to perform the standard URL encoding and also to add maintain the values of these parameters as one navigates the site.  This class may be called directly but more normally one would use the <tt><ffl:url ...></tt> tag which makes use of this class or the <tt><ffl:a ... ></tt> tag which allows us to apply standard formatting to all <tt><a ... ></tt> tags and which in turn calls <tt><ffl:url ... ></tt>.  Tags such as <tt><ffl:fantacyClub ... ></tt> are provided so that a Fantacy Club's name will be rendered consistently on all pages and include a link to the club (using <tt><ffl:a .. ></tt>).
The <tt>FantacyURLEncoder</tt> class is used to perform the standard URL encoding and also to maintain the values of these parameters as one navigates the site.  This class may be called directly but more normally one would use the <tt><ffl:url ...></tt> tag which makes use of this class or the <tt><ffl:a ... ></tt> tag which allows us to apply standard formatting to all <tt><a ... ></tt> tags and which in turn calls <tt><ffl:url ... ></tt>.  Tags such as <tt><ffl:fantacyClub ... ></tt> are provided so that a Fantacy Club's name will be rendered consistently on all pages and include a link to the club (using <tt><ffl:a .. ></tt>).

Latest revision as of 08:21, 4 September 2014

Any URLs in a Java EE web app should be run through the HttpServletResponse.encodeURL method. This is required to ensure that the session is encoded into the URL if need be.

In addition, for the FFL site, we have some parameters which we carry around as context from page to page. These are encoded into every link. They are

  • idFantacyLeague
  • idRealDivision
  • seasonStartYear

The DefaultParameterHelper class gives default values for these parameters if they are not present. However, this should only ever be the case for the first page a user hits. After that every link the user clicks should include these parameters, whether or not they are of relevance for the particular page the user is looking at. So if, for example, one changes seasonStartYear from 2014 to 2013 and clicks around the site, this value should persist and be encoded into every link.

The FantacyURLEncoder class is used to perform the standard URL encoding and also to maintain the values of these parameters as one navigates the site. This class may be called directly but more normally one would use the <ffl:url ...> tag which makes use of this class or the <ffl:a ... > tag which allows us to apply standard formatting to all <a ... > tags and which in turn calls <ffl:url ... >. Tags such as <ffl:fantacyClub ... > are provided so that a Fantacy Club's name will be rendered consistently on all pages and include a link to the club (using <ffl:a .. >).