Author: sletellier Date: 2011-05-31 18:18:16 +0200 (Tue, 31 May 2011) New Revision: 82 Url: http://chorem.org/repositories/revision/vradi/82 Log: Creation of page to view forms Added: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormViewAction.java trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formView.jsp Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties trunk/vradi-web/src/main/resources/struts.xml trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp Added: trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormViewAction.java =================================================================== --- trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormViewAction.java (rev 0) +++ trunk/vradi-web/src/main/java/org/chorem/vradi/actions/FormViewAction.java 2011-05-31 16:18:16 UTC (rev 82) @@ -0,0 +1,53 @@ +package org.chorem.vradi.actions; + +import org.apache.struts2.interceptor.ServletRequestAware; +import org.chorem.vradi.entities.Form; +import org.nuiton.wikitty.WikittyProxy; + +import javax.servlet.http.HttpServletRequest; + +/** + * Action to display form details + * + * @author sletellier + */ +public class FormViewAction extends VradiBaseAction implements ServletRequestAware { + + protected HttpServletRequest request; + protected String formId; + protected Form form; + + public String getFormId() { + return formId; + } + + public void setFormId(String formId) { + this.formId = formId; + } + + public Form getForm() { + return form; + } + + public void setForm(Form form) { + this.form = form; + } + + @Override + public void setServletRequest(HttpServletRequest request) { + this.request = request; + } + + @Override + public String execute() throws Exception { + WikittyProxy proxy = getProxy(); + Form form = proxy.restore(Form.class, getFormId()); + setForm(form); + + if (log.isDebugEnabled()) { + log.debug("Displaying form : " + form.getObjet()); + } + request.setAttribute("form", form); + return SUCCESS; + } +} Modified: trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties =================================================================== --- trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-31 15:21:39 UTC (rev 81) +++ trunk/vradi-web/src/main/resources/i18n/vradi-web_en_GB.properties 2011-05-31 16:18:16 UTC (rev 82) @@ -36,4 +36,5 @@ vradi.search.unActivateQuery=Unactivate vradi.search.activateQuery=activate vradi.search.queryName=Request name -vradi.search.saveQuery=Sauvegarder la requ\u00eate \ No newline at end of file +vradi.search.saveQuery=Save request +vradi.formView.title=Form view \ No newline at end of file Modified: trunk/vradi-web/src/main/resources/struts.xml =================================================================== --- trunk/vradi-web/src/main/resources/struts.xml 2011-05-31 15:21:39 UTC (rev 81) +++ trunk/vradi-web/src/main/resources/struts.xml 2011-05-31 16:18:16 UTC (rev 82) @@ -119,6 +119,14 @@ </action> <!-- + | Affiche le détail du formulaire + +--> + <action name="formView/*" class="org.chorem.vradi.actions.FormViewAction"> + <param name="formId">{1}</param> + <result>/WEB-INF/jsp/formView.jsp</result> + </action> + + <!-- | Affiche la liste des notes attachees a un formulaire | Permet de creer une nouvelle note +--> Added: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formView.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formView.jsp (rev 0) +++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/formView.jsp 2011-05-31 16:18:16 UTC (rev 82) @@ -0,0 +1,39 @@ +<%@ page import="org.chorem.vradi.entities.Form" %> +<%@ page import="org.chorem.vradi.entities.FormImpl" %> +<%@ page import="com.opensymphony.xwork2.ActionContext" %> +<%@ page import="org.omg.DynamicAny.FieldNameHelper" %> +<%@ page import="org.nuiton.wikitty.entities.Wikitty" %> +<%@ page import="org.nuiton.wikitty.entities.WikittyExtension" %> +<%@ page import="org.chorem.vradi.VradiSession" %> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@taglib prefix="s" uri="/struts-tags"%> + +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title><s:text name="vradi.formView.title" /></title> + </head> + <body> + <h1><s:text name="vradi.formView.title" /></h1> + <div id="content"> + <table> + <% Form form = (Form)request.getAttribute("form"); + + for (String extName : form.getExtensionNames()) { + Wikitty wikitty = VradiSession.getVradiSession(session).getProxy().getWikitty(form); + WikittyExtension extension = wikitty.getExtension(extName); + for (String fieldName : extension.getFieldNames()) { + %> + <tr> + <th><%=fieldName%></th> + <td><%=form.getField(extName, fieldName)%></td> + </tr> + <% + } + } + %> + </table> + </div> + </body> +</html> Modified: trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp =================================================================== --- trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-31 15:21:39 UTC (rev 81) +++ trunk/vradi-web/src/main/webapp/WEB-INF/jsp/search.jsp 2011-05-31 16:18:16 UTC (rev 82) @@ -72,18 +72,20 @@ <displaytag:column titleKey="vradi.form.creationDate" property="<%=Infogene.FIELD_INFOGENE_CREATIONDATE%>" sortable="true" + href="<%="formView/" + ((Form)f).getWikittyId() + ".action"%>" sortProperty="<%=Infogene.FQ_FIELD_INFOGENE_CREATIONDATE%>" decorator="<%=DateFormatColumnDecorator.class.getName()%>"/> <displaytag:column titleKey="vradi.form.object" property="<%=Infogene.FIELD_INFOGENE_OBJET%>" sortable="true" + href="<%="formView/" + ((Form)f).getWikittyId() + ".action"%>" sortProperty="<%=Infogene.FQ_FIELD_INFOGENE_OBJET%>" decorator="<%=EscapeScriptColomnDecorator.class.getName()%>"/> <displaytag:column titleKey="common.action" class="action"> - <s:set name="formNoteListURl"><%="formNoteList/" + ((Form)f).getWikittyId()%></s:set> - <s:a action="%{formNoteListURl}"><s:text name="vradi.search.formNoteEdit"/></s:a> + <s:set name="formNoteListUrl"><%="formNoteList/" + ((Form)f).getWikittyId()%></s:set> + <s:a action="%{formNoteListUrl}"><s:text name="vradi.search.formNoteEdit"/></s:a> </displaytag:column> </displaytag:table> </div>