1 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2 pageEncoding="ISO-8859-1"%>
3 <%@ taglib prefix="s" uri="/struts-tags"%>
4 <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
5 <tiles:importAttribute name="valid_action" scope="request" />
7 <script language="JavaScript">
8 function initialize() {
9 create.elements[0].focus();
13 var select = create.projectContextId.value; // contextValue select input
14 if (select == "0") { // Creation of a new context type
15 tds = document.getElementById("select");
16 tde = document.getElementById("enter");
17 tds.style.display = "none"; // Hides the select input
18 tde.style.display = "block"; // Displays the text input
20 create.projectContext.focus();
23 function setDefaultSelection() {
24 tds = document.getElementById("select");
25 tde = document.getElementById("enter");
26 tds.style.display = "block"; // Hides the select input
27 tde.style.display = "none"; // Displays the text input
29 create.projectContextId.value = -1;
30 create.projectContextId.focus();
33 $(document).ready(function() {
34 <s:if test="projectContextValues.size > 0">
35 create.projectContextId.value = <s:property value="projectContextId"/>;
39 //Studied product validation (based on struts-generated validation)
40 //relies on javascript included by 'validate="true"' for displaying error messages
41 document.getElementById("create").addEventListener('submit', function(event) { //cross-browser solution
42 form = document.getElementById("create");
45 var continueValidation = true;
47 // field name: product
48 // custom validation function
49 if (form.elements['projectContext'] && form.elements['projectContextId']) {
50 field = form.elements['projectContext'];
51 id = form.elements['projectContextId'];
52 var error = "The field \'Studied product\' must be filled";
53 if (continueValidation
54 && id.value != null && (
56 && field.value != null
57 && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)
62 addError(field, error);
67 event.preventDefault(); //cross-browser solution
74 ===========================================================================
76 <div id="article-box">
78 <s:text name="title.newstudy" />
80 <div id="top-spacer"></div>
81 <s:form id="create" name="create"
82 action="%{#request.valid_action}" method="post" validate="true" cssClass="text">
85 <td colspan="3"><s:text name="%{error}" /></td>
89 <td> <s:text name="field.studytitle" />: <span class="error">*</span>
91 <td><s:textfield theme="simple" size="60" name="title" /></td>
95 <td> <s:text name="field.product" />: <span class="error">*</span>
97 <s:if test="projectContextValues.size > 0">
98 <td id="select"><select name="projectContextId"
99 style="width: 214px" onChange="setValue()">
101 <s:text name="menu.select" />
105 <s:text name="menu.newproduct" />
107 <optgroup label=" <s:text name="label.products"/>">
108 <s:iterator value="projectContextValues">
109 <option value="<s:property value="index"/>">
111 <s:property value="value" />
116 <td id="enter" style="display: none">
117 <s:textfield theme="simple" size="30" name="projectContext" />
118 <img src="<s:url value="/skin/icon.undo.png"/>" border="none"
119 title="<s:text name="tooltip.cancel"/>"
120 onclick="setDefaultSelection()"/>
124 <td><s:hidden name="projectContextId" value="0" /> <s:textfield
125 theme="simple" size="30" name="projectContext" /></td>
128 <tiles:insertAttribute name="source_study" ignore="true" />
131 <td align="right" colspan="2"><s:submit
132 theme="simple" type="button"
133 key="button.newstudy" /></td>
137 <div id="top-spacer"></div>
142 <div id="right-pane"></div>
143 <div id="bottom-spacer"></div>