-
1. Re: Need help with using HashMap in facelets
beginner_prithvi Nov 19, 2009 4:42 AM (in response to beginner_prithvi)I think I nee to tell you what I am goint to tell with this HashMap.
I am planning to create a dynamic tabbed pane.
It will ahve number of tabs as equal to number of files. Each tab lable will be the name of the file. And inside that tab i will display the corresponding file.
I think it will help you to think in that direction. -
2. Re: Need help with using HashMap in facelets
beginner_prithvi Nov 19, 2009 6:25 AM (in response to beginner_prithvi)Presently I am trying to access HashMap in this way:
<rich:tabPanel id="myTabs" switchType="client"> <c:forEach items="#{readFile.getFileContentMap}" var="x"> <rich:tab label="#{x.name}"> </rich:tab> </c:forEach> </rich:tabPanel>
And I have defined HashMap as:public class ReadFileClass { ................. .................. Map<String, StringBuilder> fileContentMap = new HashMap<String, StringBuilder>(); ................. ................. public Map<String, StringBuilder> getFileContentMap() { return fileContentMap; } .................. ..................
But I am getting exception as:Nov 19, 2009 4:37:19 PM com.sun.facelets.FaceletViewHandler handleRenderException SEVERE: Error Rendering View[/logDisplay.xhtml] javax.el.ELException: /logDisplay.xhtml: Property 'getFileContentMap' not found on type com.cts.ReadFileClass at com.sun.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:53) at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:266) at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:261) at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886) at javax.faces.render.Renderer.encodeChildren(Renderer.java:137) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892) at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592) at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108) at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141) at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Unknown Source)
What is wrong here? -
3. Re: Need help with using HashMap in facelets
ilya_shaikovsky Nov 20, 2009 6:32 AM (in response to beginner_prithvi)http://www.velocityreviews.com/forums/t140399-jstl-accessing-map.html this could help you.
-
4. Re: Need help with using HashMap in facelets
nbelaevski Nov 20, 2009 2:08 PM (in response to beginner_prithvi)That's the reason:
Property 'getFileContentMap' not found on type com.cts.ReadFileClass
-
5. Re: Need help with using HashMap in facelets
natarajan Nov 21, 2009 12:07 AM (in response to beginner_prithvi)This is more of a facelets question.
The solution is two fold.
You need one more function in your managed beanpublic List<String> getFileContentNames(){ return new ArrayList<String>(fileContentMap.keySet()); }
And then in the XHTML, do something like this:<rich:tabPanel id="myTabs" switchType="client"> <c:forEach items="#{readFile.fileContentNames}" var="x"> <rich:tab label="#{readFile.fileContentMap[x]}"> </rich:tab> </c:forEach> </rich:tabPanel>
This is how, I made it work for UI:INCLUDE.
with regards,
Natarajan
CTS -
6. Re: Need help with using HashMap in facelets
beginner_prithvi Nov 30, 2009 6:52 AM (in response to beginner_prithvi)Hi nbelaevski,
I solved the exception. Now I am stuck up with accessing the Map in facelet.
Hi ilya_shaikovsky,
I tried the approach given in the link. It didnt work for me :(
I tried printing map keys using <c:out\>. But i couldnt. Nothing got printed on the page.
Hi Natarajan,
I tried your approach, but tab labels are simply blank. Even only one tab is getting created instead of equal to number of files.
@Ilya and Natarajan: As per Natarajan's logic I tried printing keys on console. And it is printing the names of the file perfectly. But the only thing is that it is not able to print it in facelet. Again one more query, why only one tab is getting created? Actual number of files in the folder are more than one. (Presently two)