Ramesh,

it is better to extend javax.faces.application.ViewHandler

in JSF 1.2 there is better support to be able to decorate a standard
ViewHandler impl.

On 5/30/05, Jiri Zaloudek <[EMAIL PROTECTED]> wrote:
>  
> Hi, 
> it isn't problem if you can use only WML renderkit in your application. Add
> this code to faces-config.xml: 
> <application>
>        
> <default-render-kit-id>WML_BASIC</default-render-kit-id>
>        
> </application> 
>   
> Problem is if you can use HTML and WML renderkit together. Standard
> ViewHandler support only one RenderKit - in this JSF version. So you must
> create(replace) standard ViewHandler. 
> In my diploma work I have defined URL mapping *.jsf for HTML pages and
> *.jsfw mappings for WML pages. The ViewHandler then can set right RenderKit
> from request URL. 
>   
>   
>   
> My ViewHander source code: 
> public class WapViewHandlerImpl extends
> org.apache.myfaces.application.jsp.JspViewHandlerImpl {
>     private static Log log = LogFactory.getLog(WapViewHandlerImpl.class);
>     private static final String WML_RENDERKIT_PARAM = "WML_RenderKit";
>     private static final String WML_MAPPING = "WML_Mapping";
>     
>     /** Creates a new instance of WapViewHandlerImpl */
>     public WapViewHandlerImpl() {
>     }
>     
>     /** Gets RenderKit's name and mapping from init configuration. 
>      * @return if request url containts this mapping then return specified
> renderkit. 
>      * Otherwise delegates calculating RenderKit to the
> org.apache.myfaces.application.jsp.JspViewHandlerImpl
>      */
>     public String calculateRenderKitId(FacesContext
> facesContext) {
>         String renderKit =
> facesContext.getExternalContext().getInitParameter(WML_RENDERKIT_PARAM);
>         String mapping =
> facesContext.getExternalContext().getInitParameter(WML_MAPPING);
>                 
>         if (containtMapping(facesContext, mapping))
>             return(renderKit);
>         else
>             return(super.calculateRenderKitId(facesContext));
>     }
>     
>     private boolean containtMapping(FacesContext facesContext, String
> mapping){
>         HttpServletRequest req =
> (HttpServletRequest)facesContext.getExternalContext().getRequest();
>         return(req.getRequestURI().indexOf(mapping) != -1);
>     }
>     
> }
>  
>   
> To config this ViewHandler as a defautl - add this code to faces-config: 
> <application>        
>        
> <view-handler>org.apache.myfaces.wap.webapp.WapViewHandlerImpl</view-handler>
>        
>  </application> 
>   
>   
> And the last step is define mappings and set second RenderKit in web.xml: 
> <context-param>
>     <description>Sets renderkit name for wml pages</description>
>     <param-name>WML_RenderKit</param-name>
>     <param-value>WML_BASIC</param-value>        
>   </context-param>
>   <context-param>
>     <description>Sets mapping for wml pages</description>  
>     <param-name>WML_Mapping</param-name>
>     <param-value>.jsfw</param-value>
>   </context-param> 
>   
> <!-- Faces Servlet Mapping for HTML-->
>   <servlet-mapping>
>     <servlet-name>Faces Servlet</servlet-name>
>     <url-pattern>*.jsf</url-pattern>
>   </servlet-mapping>
>   <!-- Faces Servlet Mapping for WML-->
>   <servlet-mapping>
>     <servlet-name>Faces Servlet</servlet-name>
>     <url-pattern>*.jsfw</url-pattern>
>   </servlet-mapping> 
>   
> Regards, 
> Jiri Zaloudek
>  
>  
>  ________________________________
>  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Monday, May 30, 2005 10:33 AM
> To: [email protected]
> Subject: how to set different render kit other than default
> 
>  
>  
>  
>  
> 
> Hi, 
> 
>   
> 
> How can I set other renderer kits other than HTML. Suppose if I want to call
> JSF app from a mobile. How will I configure a separate renderer for this
> type of clients. 
> 
>   
> 
> Regards, 
> 
> Ramesh 
>  
> 
> Confidentiality Notice 
> 
> The information contained in this electronic message and any attachments to
> this message are intended
> for the exclusive use of the addressee(s) and may contain confidential or
> privileged information. If
> you are not the intended recipient, please notify the sender at Wipro or
> [EMAIL PROTECTED] immediately
> and destroy all copies of this message and any attachments.
>  


-- 
Matthias Wessendorf

Reply via email to