myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omidh <om...@gmx.de>
Subject Re: addResource java.lang.ClassCastException
Date Mon, 07 May 2007 04:43:41 GMT

Try to return a String...

public String getAddResource() {
      FacesContext context = FacesContext.getCurrentInstance();
    AddResource addResource = AddResourceFactory.getInstance(context);
    addResource.addInlineScriptAtPosition(context, AddResource.BODY_END,
script1);  
    addResource.addInlineScriptAtPosition(context, AddResource.BODY_ONLOAD ,
script2);  
return "work done";
  }

I added these in my Portlet-Impl in the render() and it works so far ok
(without problems):

FacesContext fCtx = null;
		fCtx = facesContext(request, response);
		
		AddResource resource = AddResourceFactory.getInstance(fCtx);
		logger.debug("resource: "+ resource);
		
		resource.addJavaScriptAtPosition(fCtx, AddResource.HEADER_BEGIN,
"/tiny_mce/tiny_mce.js");
		
		resource.addInlineScriptAtPosition(fCtx, AddResource.HEADER_BEGIN, 
				"tinyMCE.init({" +
					"mode : \"textareas\", " +
					"theme : \"advanced\", " +
				"});");


 

Dave-53 wrote:
> 
> I tried to use 
>    <h:outputText value="#{bean.addResource}"/>
>   to add javascript.
>    
>   public String getAddResource() {
>       FacesContext context = FacesContext.getCurrentInstance();
>     AddResource addResource = AddResourceFactory.getInstance(context);
>     addResource.addInlineScriptAtPosition(context, AddResource.BODY_END,
> script1);  
>     addResource.addInlineScriptAtPosition(context, AddResource.BODY_ONLOAD
> , script2);  
>   }
>    
>   But got the following exception. I am not sure how to use AddResource in
> correct way. Thanks for help.
>    
>    
>   java.lang.ClassCastException:
> org.apache.myfaces.renderkit.html.util.DefaultAddResource$InlineScriptPositionedInfo
>         at
> org.apache.myfaces.renderkit.html.util.DefaultAddResource.writeWithFullHeader(DefaultAddResource.java:803)
>         at
> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:170)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at com.dc.web.filter.WebFilter.doFilter(WebFilter.java:77)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at
> org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
>         at
> org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at
> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>         at
> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
>         at
> org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>         at
> org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
>         at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java
> :664)
>         at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>         at
> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
>         at java.lang.Thread.run(Thread.java:595)
> 
>  
> ---------------------------------
> Need Mail bonding?
> Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
> 

-- 
View this message in context: http://www.nabble.com/addResource-java.lang.ClassCastException-tf3699006.html#a10352081
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message