[opencms-dev] Created by in Search result

Jonathan Woods jonathan.woods at scintillance.com
Thu Aug 3 13:51:46 CEST 2006


Maria -
 
The method .getUserCreated() is a method on a instance of CmsResource, not
on the class itself; so you'll need to get an instance of CmsResource.  That
makes sense, since it's a resource-specific result which you are seeking.
 
As you can see from the API for CmsSearchResult, the only method of any use
in getting hold of a resource is getPath().  Once you have a resource's
path, you can get the resource (i.e. an instance of CmsResource) from
cmsObject.readResourcePath(String relativeResourcePath) where 'cmsObject' is
an instance of 'CmsObject'.
 
You need to be careful about what requires an absolute path and what
requires a relative one.  Most methods in the OpenCms API expect or return
relative paths - that is, paths relative to the context provided in
prevailing instances of CmsObject, CmsRequestContext etc.
 
Jon

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of
maria.freixes_graells at alcatel.es
Sent: 03 August 2006 10:13
To: The OpenCms mailing list
Subject: Re: [opencms-dev] Created by in Search result


Hi people, I'm truying to obtain the UserCreate of a file in the result.jsp,
with code:
I've trying to use the CmsResource.getUserCreated() as you can see in the
following, but all the sintaxis that I've tried is wrong. 
Anyone could help me with it, please?
I don't understand what to do with:


 CmsUUID	 getUserCreated() 
          Returns the user id of the user who created this resource.	


<%@ page buffer="none" import="org.opencms.main.*, org.opencms.search.*,
org.opencms.file.*, org.opencms.util.*, org.opencms.jsp.*, java.util.*" %><%

    
    // Create a JSP action element
    org.opencms.jsp.CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);
    
    // Get the search manager
    CmsSearchManager searchManager = OpenCms.getSearchManager(); 
%>

<jsp:useBean id="search" scope="request"
class="org.opencms.search.CmsSearch">
    <jsp:setProperty name = "search" property="matchesPerPage"
param="matchesperpage"/>
    <jsp:setProperty name = "search" property="displayPages"
param="displaypages"/>
    <jsp:setProperty name = "search" property="*"/>
    <% 
            search.init(cms.getCmsObject());         
    %>
</jsp:useBean>

<html>
<head>
<title>Search result</title>
</head>

<body>
<img src=resources/logo_opencms_large.png alt="Alcatel Logo" title="Alcatel
Logo" width="250" height="63" border="0" align="right">
<h1>Search result</h1>

<%
    int resultno = 1;
    int pageno = 0;
    if (request.getParameter("searchPage")!=null) {        
        pageno = Integer.parseInt(request.getParameter("searchPage"))-1;
    }
    resultno = (pageno*search.getMatchesPerPage())+1;
    
    String fields = search.getFields();
   if (fields==null) {
       fields = request.getParameter("fields");
   }
    
   List result = search.getSearchResult();
   if (result == null) {
%>
<%
        if (search.getLastException() != null) { 
%>
<h3>Error</h3>
<%= search.getLastException().toString() %> 
<%
        }

    } else {
    
        ListIterator iterator = result.listIterator();
%>
<h3><%= search.getSearchResult().size() %> Results found for query <<%=
search.getQuery() %>> in fields <%= fields %></h3>
<%
        while (iterator.hasNext()) {
            CmsSearchResult entry = (CmsSearchResult)iterator.next();
%>

                <h3><%= resultno %>. <a href="<%=
cms.link(cms.getRequestContext().removeSiteRoot(entry.getPath())) %>"><%=
entry.getTitle() %></a> (<%= entry.getScore() %>%)</h3>
                <h4>Keywords</h6>
                <%= entry.getKeywords() %>
                <h4>Content</h6>
                <%= entry.getExcerpt() %>
                <h4>Description</h6>
                <%= entry.getDescription() %>
                                <h4>Last Modified Date</h6>
                                <%= entry.getDateLastModified() %>
                                <h4>Created by</h6>
                                <%=CmsResource.getUserCreated()%>
                                <h4>Path</h6>
                                <%= entry.getPath() %>


                                   
<HTML>

<HEAD>

</HEAD>

<BODY>
<BR>
<BR>
<BR>
</BODY>

</HTML>
                              
                                

<%
        resultno++;            
        }
    }
%> 
<%
    if (search.getPreviousUrl() != null) {
%>
        <input type="button" value="<< previous"
onclick="location.href='<%= cms.link(search.getPreviousUrl()) %>&fields=<%=
fields %>';">
<%
    }
    Map pageLinks = search.getPageLinks();
    Iterator i =  pageLinks.keySet().iterator();
    while (i.hasNext()) {
        int pageNumber = ((Integer)i.next()).intValue();
        String pageLink = cms.link((String)pageLinks.get(new
Integer(pageNumber)));    
        out.print("   ");
        if (pageNumber != search.getSearchPage()) {
%>
            <a href="<%= pageLink %>&fields=<%= fields %>"><%= pageNumber
%></a>
<%
        } else {
%>
            <span class="currentpage"><%= pageNumber %></span>
<%
        }
    }
    if (search.getNextUrl() != null) {
%>
           <input type="button" value="next >>"
onclick="location.href='<%= cms.link(search.getNextUrl()) %>&fields=<%=
fields %>';">
<%
    } 
    
%>
            
</body>


Christian Steinert escribió: 

You have to read the file yourself.



The search index gives you just some selected information. If you need more
infos then you have to read the file/folder from the virtual file system



Take a look at the class CmsResource and the method
CmsObject.readResource(...)



christian





  

-----Ursprüngliche Nachricht-----

Von: The OpenCms mailing list  <mailto:opencms-dev at opencms.org>
<opencms-dev at opencms.org>

Gesendet: 02.08.06 18:52:51

An: The OpenCms mailing list  <mailto:opencms-dev at opencms.org>
<opencms-dev at opencms.org>

Betreff: Re: [opencms-dev] Created by in Search result

    





  

I've found the PARAM_EXPLORER_FILEUSERCREATED

public static final java.lang.String Request parameter name for the 

explorer file user created from 

org-opencms.workplace.commons.CmsPreferences, but I don't know how to 

use it:





|public static final java.lang.String| 	|PARAM_EXPLORER_FILEUSERCREATED 

<org/opencms/workplace/commons/CmsPreferences.html#PARAM_EXPLORER_FILEUSERCR
EATED>| 

	|"tabexfileusercreated"|







Thanks!!!







maria.freixes_graells at alcatel.es wrote:

    

Hey!



Nobody knows a method from a class from I could obtain this value 

"created by"?



Thanks!!



maria.freixes_graells at alcatel.es wrote:

      

Hello people!



I'm using the *CmsSearchResult *class for view my searches, but I 

would like to view also de "created by"

field for a file, and this class doesn't have this method. Anyone 

knows how can I obtain the "created by" in my result?



Thanks and best regards,



Maria





_______________________________________________

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

      

_______________________________________________

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

    





_____________________________________________________________________

Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!

http://smartsurfer.web.de/?mc=100071
<http://smartsurfer.web.de/?mc=100071&distributionid=000000000071>
&distributionid=000000000071





_______________________________________________

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

  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060803/a039442c/attachment.htm>


More information about the opencms-dev mailing list