-
1. Re: how to display all XHTML files in jsf page
cash1981 Aug 26, 2009 9:59 PM (in response to seamkaruna)I wanted the same thing and asked about this earlier and I got the answer
This is not possible
. However you can do this creating a script that lists all the xhtml pages and push those in the db or show them directly. Hackish, but works. -
2. Re: how to display all XHTML files in jsf page
cash1981 Aug 26, 2009 10:01 PM (in response to seamkaruna)Here is my other post
-
3. Re: how to display all XHTML files in jsf page
swd847 Aug 27, 2009 12:26 AM (in response to seamkaruna)It should be possible. Have a look under section 30.1 'Deploying Custom Resources'.
-
4. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 9:50 AM (in response to seamkaruna)Interesting. Too bad no one answered my post. I will share my findings
-
5. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 10:14 AM (in response to seamkaruna)Hmmm I seem to have problems. I have no idea what to do in the required methods.
public Set<FileDescriptor> getResources() { } public void postProcess(ClassLoader classLoader) { } public void setResources(Set<FileDescriptor> resources) { }
Any ideas?
-
6. Re: how to display all XHTML files in jsf page
swd847 Aug 27, 2009 10:22 AM (in response to seamkaruna)Extend AbstractDeploymentHandler, something like:
package org.jboss.seam.deployment; import org.jboss.seam.contexts.Contexts; public class MyDeploymentHandler extends AbstractDeploymentHandler { private static DeploymentMetadata FILE_METADATA = new DeploymentMetadata() { public String getFileNameSuffix() { return ".xhtml"; } }; public static final String NAME = "mydeploymenthandlername; public String getName() { return NAME; } public DeploymentMetadata getMetadata() { return FILE_METADATA; } }
-
7. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 10:30 AM (in response to seamkaruna)Thanks Stuart. However, I still get the same NullPointerException
public class CustomDeploymentHandler extends AbstractDeploymentHandler { private static DeploymentMetadata CUSTOM_METADATA = new DeploymentMetadata() { public String getFileNameSuffix() { return ".xhtml"; } }; public String getName() { return "customDeploymentHandler"; } public DeploymentMetadata getMetadata() { return CUSTOM_METADATA; } }
@Name("startupDeployment") @Scope(ScopeType.APPLICATION) @Startup public class StartupDeployment { @In("#{deploymentStrategy.deploymentHandlers['customDeploymentHandler']}") private CustomDeploymentHandler myDeploymentHandler; @In("#{hotDeploymentStrategy.deploymentHandlers['customDeploymentHandler']}") private CustomDeploymentHandler myHotDeploymentHandler; @Logger private Log log; @Create public void create() { for (FileDescriptor fd : myDeploymentHandler.getResources()) { handleXhtml(fd); } for (FileDescriptor f : myHotDeploymentHandler.getResources()) { handleXhtml(f); } } public void handleXhtml(FileDescriptor fd) { log.info("Filedesc #0 #1", fd.getName(), fd.getUrl()); } }
And a seam-deployment.properties
# For standard deployment org.jboss.seam.deployment.deploymentHandlers=mypackage.CustomDeploymentHandler # For hot deployment org.jboss.seam.deployment.hotDeploymentHandlers=mypackage.CustomDeploymentHandler
I get nullpointer on myDeploymentHandler. Seems it doesnt inject it correctly.
-
8. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 11:03 AM (in response to seamkaruna)Sorry my bad. I had forgot to put the properties file in the build.xml to be copied over.
-
9. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 11:09 AM (in response to seamkaruna)I copied the deployment-properties file to the myproject.ear/META-INF/ folder and after debug it seems it only finds the debug.xhtml file. I wonder why....
-
10. Re: how to display all XHTML files in jsf page
wilczarz.wilczarz.gmail.com Aug 27, 2009 4:35 PM (in response to seamkaruna)Wouldn't this work?
public List<String> getXhtmls() { return getResources( "/", ".xhtml" ); } protected List<String> getResources( String path, String suffix ) { ExternalContext context = FacesContext.getCurrentInstance().getExternalContext(); Set<String> resources = context.getResourcePaths( path ); List<String> filteredResources = new ArrayList<String>(); for ( String resource : resources ) { if( resource.endsWith( ".xhtml" ) ) { filteredResources.add( resource ); } else if( resource.endsWith( "/" ) ) { filteredResources.addAll( getResources( resource, suffix ) ); } } return filteredResources; }
<h:dataTable value="#{someBean.xhtmls}" var="page"> <h:column> <h:outputText value="#{page}" /> </h:column> </h:dataTable>
-
11. Re: how to display all XHTML files in jsf page
wilczarz.wilczarz.gmail.com Aug 27, 2009 4:38 PM (in response to seamkaruna)Sorry, typo. Should've been
public List<String> getXhtmls() { return getResources( "/", ".xhtml" ); } protected List<String> getResources( String path, String suffix ) { ExternalContext context = FacesContext.getCurrentInstance().getExternalContext(); Set<String> resources = context.getResourcePaths( path ); List<String> filteredResources = new ArrayList<String>(); for ( String resource : resources ) { if( resource.endsWith( suffix ) ) { filteredResources.add( resource ); } else if( resource.endsWith( "/" ) ) { filteredResources.addAll( getResources( resource, suffix ) ); } } return filteredResources; }
Cheers!
-
12. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 4:45 PM (in response to seamkaruna)So is that instead of the custom deployment?
-
13. Re: how to display all XHTML files in jsf page
cash1981 Aug 27, 2009 4:51 PM (in response to seamkaruna)This worked btw :-)
Thanks -
14. Re: how to display all XHTML files in jsf page
seamkaruna Aug 28, 2009 11:28 AM (in response to seamkaruna)hi shervin can u post the code for displaying all XHTML files in jsf page, plz its very urgent.
thanks in advance.