[opencms-dev] get title of resource with jstl
chapmanl99
chapmanl99 at aol.com
Wed Apr 21 04:00:15 CEST 2010
I would like to use this code but give it a variable containing the filename.
I'm trying to produce a list of files in a folder using the Title property
of each file. There are several code examples on the web but none that I
can find work correctly. This is what I have so far. I used your suggestion
for the two cms tagTitle lines but they produce an error.
<%@ page session="false" buffer="none" import="java.sql.*, com.onr.*,
java.util.*,org.opencms.search.*, org.opencms.flex.*, org.opencms.util.*,
org.opencms.jsp.*, org.opencms.frontend.templateone.modules.*,
org.opencms.main.*, org.opencms.file.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<jsp:useBean id="cmsUser" class="org.opencms.jsp.CmsJspActionElement">
<% cmsUser.init(pageContext, request, response); %>
</jsp:useBean>
<%
CmsJspActionElement action = new
CmsJspActionElement(pageContext,request,response);
CmsObject cms = action.getCmsObject();
try {
List listFolders =
cms.getSubFolders(action.info("opencms.request.folder"));
CmsFolder cmsfolder= null;
for(int i=0;i<listFolders.size();i++){
cmsfolder=(CmsFolder) listFolders.get(i);
%>
"<cms:link /<%=cmsfolder.getName()%></cms:link>"><%=cmsfolder.getName()%>
<% out.println("<br>");
}
List listFiles =
cms.getFilesInFolder(action.info("opencms.request.folder"));
for(int i=0;i<listFiles.size();i++){
CmsFile cmsfile= (CmsFile) listFiles.get(i);
String propertyname = "title";
String filename = cmsfile.getName();
%>
<cms:titleTag file='site-event-reporting.jsp'/>
<cms:titleTag file = filename/>
"<cms:link /<%=cmsfile.getName()%></cms:link>"><%=cmsfile.getName()%>
<% out.println("<br>");
}
} catch (CmsException e) {
out.println(e);
}
%>
These two lines in the middle of the code:
<cms:titleTag file='site-event-reporting.jsp'/>
<cms:titleTag file = filename/>
do not work for me. I get "No tag "titleTag" defined in the library
imported with prefix cms" error. I'm using opencms 6. Could that be the
problem. I would appreciate any help with this.
Lynn
Yves Glodt-5 wrote:
>
> On Wednesday 18 February 2009, Yves Glodt wrote:
>> Hello,
>>
>> is there a way to get the title of a resource with an opencms tag, à la
>> <cms:titleTag file="/folder/file.html" /> ?
>
> Fool, of course it is!
>
> <cms:property name='Title' file='/en/sitemap.html' />
>
> doc-reading helps... :-)
>
>> best regards,
>> Yves
>>
>>
>> _______________________________________________
>> This mail is sent to you from the opencms-dev mailing list
>> To change your list options, or to unsubscribe from the list, please
>> visit
>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
--
View this message in context: http://old.nabble.com/get-title-of-resource-with-jstl-tp22080788p28287942.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
More information about the opencms-dev
mailing list