dev@jsftemplating.java.net

Re: JSFTemplating: review request

From: Senthil Chidambaram <cchidamb_at_sun.com>
Date: Wed, 07 Mar 2007 15:01:48 -0800

Jennifer,
I think mbyurl can be done using our urlencode handler that is available
today. We may need to enhance this to encode parameters as well, which
we've not done yet, but this can be used even for encoding params, not
efficient though. We may need an handler which encodes both URL, and
parameters. I think this is what you're asking for, no we don't have it yet.


thx
Senthil

Jennifer Chou wrote:

> Hi Senthil,
>
> I haven't actually done the mbyte url parsing and encoding yet. You
> change doesn't change what I need to do for mbyte url right?
>
> Jennifer
>
> Senthil Chidambaram wrote:
>
>> I'm attaching the diffs for three files LayoutViewHandler.java,
>> Util.java, and UtilHanlders.java which takes care of setting encoding
>> type, and client locale.
>>
>> This is the logic I'm using if an app level encoding type is set use
>> it, if not look for page level encoding type, then try client
>> encoding type, and finally hard coding it to UTF-8.
>>
>> You can see the above logic in utildiff file, and the handler method
>> I've added to set page level encoding type is in handlersdiff.
>> LayoutViewHandlerdiff is where the page is being served to the client.
>>
>> P.S: I know Ken is off, but I would appreciate if you any one of you
>> could review it, and let me know. I can checkin the changes.
>> ------------------------------------------------------------------------
>>
>> Index: LayoutViewHandler.java
>> ===================================================================
>> RCS file:
>> /cvs/jsftemplating/src/java/com/sun/jsftemplating/layout/LayoutViewHandler.java,v
>>
>> retrieving revision 1.19
>> diff -c -r1.19 LayoutViewHandler.java
>> *** LayoutViewHandler.java 1 Mar 2007 04:41:50 -0000 1.19
>> --- LayoutViewHandler.java 7 Mar 2007 22:01:30 -0000
>> ***************
>> *** 514,526 ****
>> contentTypeList = "text/html;q=1.0";
>> }
>> }
>> ! String encType = request.getCharacterEncoding();
>> ! if(encType != null && encType.length() > 0) {
>> ! response.setCharacterEncoding(encType);
>> ! }
>> ! else {
>> ! response.setCharacterEncoding("UTF-8");
>> }
>> // FIXME: Portlet?
>> writer =
>> --- 514,527 ----
>> contentTypeList = "text/html;q=1.0";
>> }
>> }
>> ! String encType = Util.getEncoding(context);
>> ! if(encType == null) {
>> ! encType = request.getCharacterEncoding();
>> ! if(encType == null) {
>> ! encType="UTF-8";
>> ! }
>> }
>> + response.setCharacterEncoding(encType);
>> // FIXME: Portlet?
>> writer =
>>
>> ------------------------------------------------------------------------
>>
>> Index: Util.java
>> ===================================================================
>> RCS file:
>> /cvs/jsftemplating/src/java/com/sun/jsftemplating/util/Util.java,v
>> retrieving revision 1.6
>> diff -c -r1.6 Util.java
>> *** Util.java 16 Nov 2006 19:22:33 -0000 1.6
>> --- Util.java 7 Mar 2007 22:02:45 -0000
>> ***************
>> *** 29,34 ****
>> --- 29,36 ----
>> import javax.faces.component.UIViewRoot;
>> import javax.faces.context.FacesContext;
>> + import com.sun.jsftemplating.el.PageSessionResolver;
>> + /**
>> * <p> This class is for general purpose utility methods.</p>
>> ***************
>> *** 97,102 ****
>> --- 99,122 ----
>> // Return the result
>> return props;
>> }
>> + /**
>> + * <p> Help obtain the current encoding type.</p>
>> + */
>> + + public static String getEncoding(FacesContext ctx) {
>> + String encType = null;
>> + if (ctx != null) {
>> + encType =
>> ctx.getExternalContext().getInitParameter("ENCODING_TYPE");
>> + if(encType == null) {
>> + UIViewRoot root = ctx.getViewRoot();
>> + Map map = PageSessionResolver.getPageSession(ctx,
>> root);
>> + if(map != null) {
>> + encType = (String)map.get("encoding");
>> + }
>> + }
>> + }
>> + return encType;
>> + }
>> /**
>> * <p> Help obtain the current <code>Locale</code>.</p>
>>
>> ------------------------------------------------------------------------
>>
>> Index: UtilHandlers.java
>> ===================================================================
>> RCS file:
>> /cvs/jsftemplating/src/java/com/sun/jsftemplating/handlers/UtilHandlers.java,v
>>
>> retrieving revision 1.14
>> diff -c -r1.14 UtilHandlers.java
>> *** UtilHandlers.java 6 Nov 2006 08:53:50 -0000 1.14
>> --- UtilHandlers.java 7 Mar 2007 22:03:01 -0000
>> ***************
>> *** 374,379 ****
>> --- 374,396 ----
>> }
>> /**
>> + * <p> This handler sets the encoding type of the given
>> UIComponent's
>> + * attribute map.</p>
>> + *
>> + * @param context The HandlerContext.
>> + */
>> + @Handler(id="setEncoding",
>> + input={
>> + @HandlerInput(name="value", type=String.class)
>> + },
>> + output={
>> + @HandlerOutput(name="value", type=String.class)})
>> + public static void setEncoding(HandlerContext context) {
>> + String value = (String) context.getInputValue("value");
>> + context.setOutputValue("value", value);
>> + }
>> + + /**
>> * <p> This handler prints out the contents of the given
>> UIComponent's
>> * attribute map.</p>
>> *
>>
>