Work on FreeMarker version of individual list page
This commit is contained in:
parent
4aa300e5a3
commit
c4709265c4
10 changed files with 65 additions and 50 deletions
|
@ -87,14 +87,10 @@ public class BrowseController extends FreeMarkerHttpServlet {
|
||||||
body.put("message", message);
|
body.put("message", message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
List<VClassGroupView> vcgroups = new ArrayList<VClassGroupView>();
|
List<VClassGroupView> vcgroups = new ArrayList<VClassGroupView>(groups.size());
|
||||||
Iterator<VClassGroup> i = groups.iterator();
|
Iterator<VClassGroup> i = groups.iterator();
|
||||||
VClassGroup group;
|
|
||||||
VClassGroupView displayGroup;
|
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
group = (VClassGroup) i.next();
|
vcgroups.add(new VClassGroupView(i.next()));
|
||||||
displayGroup = new VClassGroupView(group);
|
|
||||||
vcgroups.add(displayGroup);
|
|
||||||
}
|
}
|
||||||
body.put("classGroups", vcgroups);
|
body.put("classGroups", vcgroups);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class CommentFormController extends FreeMarkerHttpServlet {
|
||||||
else {
|
else {
|
||||||
|
|
||||||
ApplicationBean appBean = vreq.getAppBean();
|
ApplicationBean appBean = vreq.getAppBean();
|
||||||
int portalId = portal.getPortalId();
|
|
||||||
|
|
||||||
String portalType = null;
|
String portalType = null;
|
||||||
if ( (appBean.getMaxSharedPortalId()-appBean.getMinSharedPortalId()) > 1
|
if ( (appBean.getMaxSharedPortalId()-appBean.getMinSharedPortalId()) > 1
|
||||||
|
@ -72,6 +71,8 @@ public class CommentFormController extends FreeMarkerHttpServlet {
|
||||||
}
|
}
|
||||||
body.put("portalType", portalType);
|
body.put("portalType", portalType);
|
||||||
|
|
||||||
|
body.put("portalId", portalId);
|
||||||
|
|
||||||
// Not used in template. Is it used in processing the form?
|
// Not used in template. Is it used in processing the form?
|
||||||
if (vreq.getHeader("Referer") == null) {
|
if (vreq.getHeader("Referer") == null) {
|
||||||
vreq.getSession().setAttribute("commentsFormReferer","none");
|
vreq.getSession().setAttribute("commentsFormReferer","none");
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
protected VitroRequest vreq;
|
protected VitroRequest vreq;
|
||||||
protected HttpServletResponse response;
|
protected HttpServletResponse response;
|
||||||
protected Portal portal;
|
protected Portal portal;
|
||||||
|
protected int portalId;
|
||||||
protected String appName;
|
protected String appName;
|
||||||
protected Map<String, Object> root = new HashMap<String, Object>();
|
protected Map<String, Object> root = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
@ -178,15 +179,17 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
// RY Can this be removed? Do templates need it? Ideally, they should not.
|
// RY Can this be removed? Do templates need it? Ideally, they should not.
|
||||||
// Only needed for some weird stuff in search box that I think is only used in old default theme.
|
// Only needed for some weird stuff in search box that I think is only used in old default theme.
|
||||||
int portalId = portal.getPortalId();
|
// Some forms need it also, in which case it should get set in the getBody() method and passed to that
|
||||||
setSharedVariable("portalId", portalId);
|
// body template.
|
||||||
|
portalId = portal.getPortalId();
|
||||||
|
root.put("portalId", portalId);
|
||||||
|
|
||||||
appName = portal.getAppName();
|
appName = portal.getAppName();
|
||||||
setSharedVariable("siteName", appName);
|
setSharedVariable("siteName", appName);
|
||||||
|
|
||||||
setTemplateLoader();
|
setTemplateLoader();
|
||||||
|
|
||||||
TabMenu menu = getTabMenu(portalId);
|
TabMenu menu = getTabMenu();
|
||||||
root.put("tabMenu", menu);
|
root.put("tabMenu", menu);
|
||||||
|
|
||||||
ApplicationBean appBean = vreq.getAppBean();
|
ApplicationBean appBean = vreq.getAppBean();
|
||||||
|
@ -198,7 +201,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
String themeDir = getThemeDir();
|
String themeDir = getThemeDir();
|
||||||
|
|
||||||
setUrls(portalId, themeDir);
|
setUrls(themeDir);
|
||||||
setLoginInfo();
|
setLoginInfo();
|
||||||
setCopyrightInfo();
|
setCopyrightInfo();
|
||||||
setThemeInfo(themeDir);
|
setThemeInfo(themeDir);
|
||||||
|
@ -214,7 +217,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
// Define the URLs that are accessible to the templates. Note that we do not create menus here,
|
// Define the URLs that are accessible to the templates. Note that we do not create menus here,
|
||||||
// because we want the templates to be free to define the link text and where the links are displayed.
|
// because we want the templates to be free to define the link text and where the links are displayed.
|
||||||
private final void setUrls(int portalId, String themeDir) {
|
private final void setUrls(String themeDir) {
|
||||||
// The urls that are accessible to the templates.
|
// The urls that are accessible to the templates.
|
||||||
// NB We are not using our menu object mechanism to build menus here, because we want the
|
// NB We are not using our menu object mechanism to build menus here, because we want the
|
||||||
// view to control which links go where, and the link text and title.
|
// view to control which links go where, and the link text and title.
|
||||||
|
@ -240,8 +243,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
urls.put("termsOfUse", getUrl(Routes.TERMS_OF_USE, portalParam));
|
urls.put("termsOfUse", getUrl(Routes.TERMS_OF_USE, portalParam));
|
||||||
urls.put("login", getUrl(Routes.LOGIN));
|
urls.put("login", getUrl(Routes.LOGIN));
|
||||||
|
|
||||||
Map<String, String> logoutParams = new HashMap<String, String>();
|
Map<String, String> logoutParams = new HashMap<String, String>(portalParam);
|
||||||
logoutParams.put("home", "" + portalId);
|
|
||||||
logoutParams.put("loginSubmitMode", "Log Out");
|
logoutParams.put("loginSubmitMode", "Log Out");
|
||||||
urls.put("logout", getUrl(Routes.LOGOUT, logoutParams));
|
urls.put("logout", getUrl(Routes.LOGOUT, logoutParams));
|
||||||
|
|
||||||
|
@ -329,7 +331,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TabMenu getTabMenu(int portalId) {
|
private TabMenu getTabMenu() {
|
||||||
return new TabMenu(vreq, portalId);
|
return new TabMenu(vreq, portalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreeMarkerHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreeMarkerHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.view.ViewObject;
|
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.DefaultObjectWrapper;
|
import freemarker.template.DefaultObjectWrapper;
|
||||||
import freemarker.template.TemplateException;
|
import freemarker.template.TemplateException;
|
||||||
|
|
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -62,13 +63,13 @@ public class IndividualListController extends FreeMarkerHttpServlet {
|
||||||
response.sendRedirect(Routes.BROWSE + "?"+vreq.getQueryString());
|
response.sendRedirect(Routes.BROWSE + "?"+vreq.getQueryString());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new HelpException("EntityListControllerFM: request parameter 'vclassId' must be a URI string");
|
throw new HelpException("IndividualListController: request parameter 'vclassId' must be a URI string");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (obj instanceof VClass) {
|
} else if (obj instanceof VClass) {
|
||||||
vclass = (VClass)obj;
|
vclass = (VClass)obj;
|
||||||
} else {
|
} else {
|
||||||
throw new HelpException("EntityListControllerFM: attribute 'vclass' must be of type "
|
throw new HelpException("IndividualListController: attribute 'vclass' must be of type "
|
||||||
+ VClass.class.getName() );
|
+ VClass.class.getName() );
|
||||||
}
|
}
|
||||||
if (vclass!=null){
|
if (vclass!=null){
|
||||||
|
@ -96,12 +97,16 @@ public class IndividualListController extends FreeMarkerHttpServlet {
|
||||||
|
|
||||||
// Create list of individuals
|
// Create list of individuals
|
||||||
List<Individual> individualList = vreq.getWebappDaoFactory().getIndividualDao().getIndividualsByVClass(vclass);
|
List<Individual> individualList = vreq.getWebappDaoFactory().getIndividualDao().getIndividualsByVClass(vclass);
|
||||||
List<IndividualView> individuals = new ArrayList<IndividualView>();
|
List<IndividualView> individuals = new ArrayList<IndividualView>(individualList.size());
|
||||||
|
Iterator<Individual> i = individualList.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
individuals.add(new IndividualView(i.next()));
|
||||||
|
}
|
||||||
body.put("individuals", individuals);
|
body.put("individuals", individuals);
|
||||||
|
|
||||||
// But the JSP version includes url rewriting via URLRewritingHttpServletResponse
|
// But the JSP version includes url rewriting via URLRewritingHttpServletResponse
|
||||||
body.put("individualUrl", config.getSharedVariable("contextPath") + "/entity?home=" + config.getSharedVariable("portalId") + "&uri=");
|
// RY *** FIX - define getUrl method of IndividualView
|
||||||
|
body.put("individualUrl", getUrl("/entity?home=" + portalId + "&uri="));
|
||||||
|
|
||||||
if (individuals == null) {
|
if (individuals == null) {
|
||||||
log.error("individuals list is null");
|
log.error("individuals list is null");
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class Routes {
|
||||||
public static final String BROWSE = "/browse";
|
public static final String BROWSE = "/browse";
|
||||||
public static final String COMMENT_FORM = "/comments";
|
public static final String COMMENT_FORM = "/comments";
|
||||||
public static final String INDIVIDUAL = "/individual";
|
public static final String INDIVIDUAL = "/individual";
|
||||||
public static final String INDIVIDUAL_LIST = "/entitylist"; // change
|
public static final String INDIVIDUAL_LIST = "/entitylist"; // "/individuallist";
|
||||||
public static final String SEARCH = "/search";
|
public static final String SEARCH = "/search";
|
||||||
public static final String TERMS_OF_USE = "/termsOfUse";
|
public static final String TERMS_OF_USE = "/termsOfUse";
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,8 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.Routes;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.Routes;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||||
|
|
||||||
public class IndividualView extends ViewObject {
|
public class IndividualView extends ViewObject {
|
||||||
|
|
||||||
|
@ -26,8 +25,9 @@ public class IndividualView extends ViewObject {
|
||||||
return individual.getName();
|
return individual.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMoniker() {
|
public String getTagline() {
|
||||||
return individual.getMoniker();
|
String tagline = individual.getMoniker();
|
||||||
|
return StringUtils.isEmpty(tagline) ? individual.getVClass().getName() : tagline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
|
@ -36,10 +36,18 @@ public class IndividualView extends ViewObject {
|
||||||
|
|
||||||
// Or maybe getProfileUrl - there might be other kinds of urls
|
// Or maybe getProfileUrl - there might be other kinds of urls
|
||||||
// e.g., getEditUrl, getDeleteUrl - these would return the computations of PropertyEditLinks
|
// e.g., getEditUrl, getDeleteUrl - these would return the computations of PropertyEditLinks
|
||||||
// Just call getUrl...
|
// RY **** Need to account for everything in URLRewritingHttpServlet
|
||||||
public String getProfileUrl() {
|
public String getProfileUrl() {
|
||||||
//return contextPath + URL + ""; // ADD IN the label from the individual's uri
|
return getUrl("/individual/" + individual.getLocalName());
|
||||||
return ""; // RY FIX THIS
|
}
|
||||||
|
|
||||||
|
public String getRenderer() {
|
||||||
|
// TODO
|
||||||
|
// iterate through class hierarchy looking for a custom renderer. If none, use
|
||||||
|
// default individual renderer. template will just do an include on individual.renderer
|
||||||
|
// Use individual.getVClasses() - this is the class hierarchy
|
||||||
|
// Question: what order are they returned in ? If from specific to general, break out of the iteration as soon as we find one.
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomView() {
|
public String getCustomView() {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.view;
|
package edu.cornell.mannlib.vitro.webapp.view;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -31,4 +33,21 @@ public abstract class ViewObject {
|
||||||
return FreeMarkerHttpServlet.urlEncode(str);
|
return FreeMarkerHttpServlet.urlEncode(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* public static List<?> wrapList(List<?> list, Class cl)
|
||||||
|
* throw error if cl not a child of ViewObject
|
||||||
|
* This block of code is going to be repeated a lot:
|
||||||
|
List<VClassGroup> groups = // code to get the data
|
||||||
|
List<VClassGroupView> vcgroups = new ArrayList<VClassGroupView>(groups.size());
|
||||||
|
Iterator<VClassGroup> i = groups.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
vcgroups.add(new VClassGroupView(i.next()));
|
||||||
|
}
|
||||||
|
body.put("classGroups", vcgroups);
|
||||||
|
Can we generalize it to a generic method of ViewObject - wrapList() ?
|
||||||
|
static method of ViewObject
|
||||||
|
Params: groups, VClassGroupView (the name of the class) - but must be a child of ViewObject
|
||||||
|
Return: List<viewObjectType>
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
|
|
||||||
<div class="entityList">
|
<div class="individualList">
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
<c:if test="${!empty subTitle}"><h4>${subTitle}"</h4></c:if>
|
<c:if test="${!empty subTitle}"><h4>${subTitle}"</h4></c:if>
|
||||||
|
|
||||||
|
|
|
@ -4,32 +4,17 @@
|
||||||
|
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
|
|
||||||
<div class="entityList">
|
<div class="individualList">
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
<#if subtitle??>
|
<#if subtitle??>
|
||||||
<h4>${subTitle}"</h4>
|
<h4>${subTitle}"</h4>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
|
<#-- RY NEED TO ACCOUNT FOR p:process stuff -->
|
||||||
<ul>
|
<ul>
|
||||||
<#list entities as entity>
|
<#list individuals as individual>
|
||||||
<#-- Iterate through the object's class hierarchy, looking for a custom view -->
|
|
||||||
<#-- RY This should be done in a view method -->
|
|
||||||
<#list entity.VClasses as type>
|
|
||||||
<#if type.customSearchView?has_content>
|
|
||||||
<#assign altRender = type.customSearchView>
|
|
||||||
<#-- What order are these returned in? If from specific to general, we should break if we find one -->
|
|
||||||
</#if>
|
|
||||||
</#list>
|
|
||||||
<li>
|
<li>
|
||||||
<#-- RY Create a directive to work like c:url with c:param -->
|
<a href="${individual.profileUrl}">${individual.name}</a> ${individual.tagline}
|
||||||
<#-- RY The JSP version includes URL rewriting in a filter - see URLRewritingHttpServletResponse -->
|
|
||||||
<a href="${entityUrl}${entity.URI?url}">${entity.name}</a> | <#-- add p:process to name -->
|
|
||||||
<#if entity.moniker?has_content>
|
|
||||||
${entity.moniker} <#-- add p:process -->
|
|
||||||
<#else>
|
|
||||||
${entity.VClass.name}
|
|
||||||
</#if>
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</#list>
|
</#list>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue