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 $(document).ready(function() {
24 <s:if test="projectContextValues.size > 0">
25 create.projectContextId.value = <s:property value="projectContextId"/>;
29 //Studied product validation (based on struts-generated validation)
30 //relies on javascript included by 'validate="true"' for displaying error messages
31 document.getElementById("create").addEventListener('submit', function(event) { //cross-browser solution
32 form = document.getElementById("create");
35 var continueValidation = true;
37 // field name: product
38 // custom validation function
39 if (form.elements['projectContext'] && form.elements['projectContextId']) {
40 field = form.elements['projectContext'];
41 id = form.elements['projectContextId'];
42 var error = "The field \'Studied product\' must be filled";
43 if (continueValidation
44 && id.value != null && (
46 && field.value != null
47 && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)
52 addError(field, error);
57 event.preventDefault(); //cross-browser solution
61 function setDefaultSelection()(event) {
62 tds = document.getElementById("select");
63 tde = document.getElementById("enter");
64 tds.style.display = "block"; // Hides the select input
65 tde.style.display = "none"; // Displays the text input
67 create.projectContextId.value = -1;
68 create.projectContextId.focus();
78 ===========================================================================
80 <div id="article-box">
82 <s:text name="title.newstudy" />
84 <div id="top-spacer"></div>
85 <s:form id="create" name="create"
86 action="%{#request.valid_action}" method="post" validate="true" cssClass="text">
89 <td colspan="3"><s:text name="%{error}" /></td>
93 <td> <s:text name="field.studytitle" />: <span class="error">*</span>
95 <td><s:textfield theme="simple" size="60" name="title" /></td>
99 <td> <s:text name="field.product" />: <span class="error">*</span>
101 <s:if test="projectContextValues.size > 0">
102 <td id="select"><select name="projectContextId"
103 style="width: 214px" onChange="setValue()">
105 <s:text name="menu.select" />
109 <s:text name="menu.newproduct" />
111 <optgroup label=" <s:text name="label.products"/>">
112 <s:iterator value="projectContextValues">
113 <option value="<s:property value="index"/>">
115 <s:property value="value" />
120 <td id="enter" style="display: none"><s:textfield
121 theme="simple" size="30" name="projectContext" /></td>
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>