pvollenweider 2005/06/24 16:13:17 CEST
Modified files: (Branch: JAHIA-4-1-BRANCH)
src/view/jsp simple_form_generator.jsp
Added files: (Branch: JAHIA-4-1-BRANCH)
src/view/jsp/include simple_form_generator_definitions.inc
simple_form_generator_display_form.inc
simple_form_generator_process_post.inc
Log:
Add checks for mandatory fields
Revision Changes Path
1.1.2.1 +41 -0
corporate_portal_templates/src/view/jsp/include/simple_form_generator_definitions.inc
(new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/simple_form_generator_definitions.inc?rev=1.1.2.1&content-type=text/plain
1.1.2.1 +238 -0
corporate_portal_templates/src/view/jsp/include/simple_form_generator_display_form.inc
(new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/simple_form_generator_display_form.inc?rev=1.1.2.1&content-type=text/plain
1.1.2.1 +59 -0
corporate_portal_templates/src/view/jsp/include/simple_form_generator_process_post.inc
(new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/simple_form_generator_process_post.inc?rev=1.1.2.1&content-type=text/plain
1.1.2.2 +6 -212
corporate_portal_templates/src/view/jsp/simple_form_generator.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/simple_form_generator.jsp.diff?r1=1.1.2.1&r2=1.1.2.2&f=h
Index: simple_form_generator.jsp
===================================================================
RCS file:
/home/cvs/repository/corporate_portal_templates/src/view/jsp/Attic/simple_form_generator.jsp,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- simple_form_generator.jsp 23 Jun 2005 15:55:56 -0000 1.1.2.1
+++ simple_form_generator.jsp 24 Jun 2005 14:13:17 -0000 1.1.2.2
@@ -1,4 +1,9 @@
<%@ include file="include/header.inc"%>
+<%@ include file="include/simple_form_generator_definitions.inc"%>
+<%
+Vector emptyMandatoryFields = new Vector();
+%>
+<%@ include file="include/simple_form_generator_process_post.inc"%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="159" valign="top"><%@ include
file="include/left_menu.inc"%></td>
@@ -9,221 +14,10 @@
<jsp:include page="include/main_content.jsp" flush="true">
<jsp:param name="id" value="main_1"/>
</jsp:include>
+ <%@ include file="include/simple_form_generator_display_form.inc"%>
-<content:declareContainerList name="forms" title="List of forms">
-<content:declareContainer>
- <content:declareField name="sender" title="Sender" type="SharedSmallText"
- titleKey="form.sender" bundleKey="<%=resBundleID%>"/>
- <content:declareField name="recipients" title="Recipients, separated by
comas"
- type="SharedSmallText" titleKey="form.recipients"
- bundleKey="<%=resBundleID%>"/>
- <content:declareField name="recipientsCC" title="Recipients CC,
separated by comas"
- type="SharedSmallText" titleKey="form.recipientsCC"
- bundleKey="<%=resBundleID%>"/>
- <content:declareField name="subject" title="Subject"
type="SharedSmallText"
- titleKey="form.Subject" bundleKey="<%=resBundleID%>"/>
- <content:declareField name="alertText" title="Alert text for mandatory
fields"
- type="BigText" titleKey="form.alertText" bundleKey="<%=resBundleID%>"
- value=""/>
- <content:declareField name="pageRedirected"
- title="Page redirected to after submission" type="Page"
- titleKey="form.pageRedirected" bundleKey="<%=resBundleID%>"/>
-
- <content:declareContainerList name="fields" title="List of fields">
- <content:declareContainer>
- <content:declareField name="fieldTitle" title="Title"
type="SmallText"
- titleKey="form.title" bundleKey="<%=resBundleID%>"/>
- <content:declareField name="isMandatory" title="Mandatory"
type="Boolean"
- titleKey="form.isMandatory" bundleKey="<%=resBundleID%>"/>
- <%
- String formTypes[] = {"singleLine","smallTextarea","largeTextarea",
- "radioButtons","selectBox","checkboxes","submitButton" };
- %>
- <content:declareField name="type" title="Type" type="SharedSmallText"
- titleKey="form.type" bundleKey="<%=resBundleID%>"
- value="<%=getMultivalues(resBundleID,formTypes)%>"/>
- <content:declareField name="defaultValue" title="Default value(s)
separated by semi-column ':'" type="SmallText"
- titleKey="form.isMandatory" bundleKey="<%=resBundleID%>"/>
-
- </content:declareContainer>
- </content:declareContainerList>
-</content:declareContainer>
-</content:declareContainerList>
-
-<%
-JahiaContainerList forms = jData.containers().getContainerList( "forms" );
-if (forms != null) {
- ContainerListBean formsBean = new ContainerListBean(forms,jParams);
- jData.gui().html().drawBeginActionMenu(formsBean ,
- null, null, true, "", "jahiatemplates.Corporate_portal_templates",
null, out);
- Enumeration formsEnum = forms.getContainers();
- boolean isFormOK = false;
- while (formsEnum.hasMoreElements()) {
- JahiaContainer form = (JahiaContainer) formsEnum.nextElement();
- ContainerBean formBean = new ContainerBean(form,jParams);
- String sender = form.getFieldValue("sender","Please insert a
sender");
- String recipients = form.getFieldValue("recipients","Please insert a
sender");
- String recipientsCC = form.getFieldValue("recipientsCC","");
- String subject = form.getFieldValue("subject","");
- String alertText = form.getFieldValue("alertText","");
- JahiaPage pageRedirected = (JahiaPage)
form.getFieldObject("pageRedirected" );
-
- isFormOK = ! ("".equals(sender) || "".equals( recipientsCC ));
-
- if (jData.gui().isEditMode()) {
- jData.gui().html().drawBeginActionMenu(formBean ,
- null, null, true, "",
"jahiatemplates.Corporate_portal_templates", null, out);
- %>
- <strong <%if ("".equals(sender)) {
%>style="color:red;"<%}%>>Sender: </strong><%=sender%><br/>
- <strong <%if ("".equals(recipients)) {
%>style="color:red;"<%}%>>Recipients: </strong><%=recipients%><br/>
- <%
- if (! "".equals( recipientsCC )){
- %>
- <strong>Recipients CC: </strong><%=recipientsCC%><br/>
- <%
- }
- %>
- <strong <%if ("".equals(alertText)) {
%>style="color:red;"<%}%>>Alert text for mandatory fields:
</strong><%=alertText%><br/>
- <%
- jData.gui().html().drawEndActionMenu(formBean ,
- null, null, true, "",
"jahiatemplates.Corporate_portal_templates", null, out);
- }
-
- if (isFormOK) {
- JahiaContainerList fields = form.getContainerList( "fields" );
- if (fields != null) {
- ContainerListBean fieldsBean = new
ContainerListBean(fields,jParams);
- jData.gui().html().drawBeginActionMenu(fieldsBean , null,
- null, true,
"","jahiatemplates.Corporate_portal_templates",
- null, out);
- %>
- <form method="post" action="<%=bypassUrl%>"
- name="form_<%=form.getID()%>"
id="form_<%=form.getID()%>">
- <table>
- <%
-
- Enumeration fieldsEnum = fields.getContainers();
- while (fieldsEnum.hasMoreElements()) {
- JahiaContainer currentField = (JahiaContainer)
fieldsEnum.nextElement();
- ContainerBean currentFieldBean = new
ContainerBean(currentField,jParams);
- String fieldTitle =
currentField.getFieldValue("fieldTitle","");
- String isMandatory =
currentField.getFieldValue("isMandatory","");
- String type = currentField.getFieldValue("type","");
- String defaultValue =
currentField.getFieldValue("defaultValue","");
- %>
- <tr>
- <td>
- <%
- if (!
ResourceBundleMarker.drawMarker(resBundleID,"submitButton","").equals(type)){
- %><strong><%=fieldTitle%>:</strong><%
- }
-
jData.gui().html().drawBeginActionMenu(currentFieldBean ,
- null, null, false, "",
- "jahiatemplates.Corporate_portal_templates",
- null, out);
- %>
- </td>
- <td>
- <%
- if
(ResourceBundleMarker.drawMarker(resBundleID,"smallTextarea","").equals(type)) {
- %>
- <textarea
name="field_<%=currentField.getID()%>"
- cols="40"
rows="6"><%=defaultValue%></textarea>
- <%
- } else if
(ResourceBundleMarker.drawMarker(resBundleID,"largeTextarea","").equals(type)) {
- %>
- <textarea
name="field_<%=currentField.getID()%>"
- cols="40"
rows="6"><%=defaultValue%></textarea>
- <%
- } else if
(ResourceBundleMarker.drawMarker(resBundleID,"radioButtons","").equals(type)) {
- if (! "".equals(defaultValue)) {
- String[] values =
defaultValue.split(":");
- for (int x=0; x<values.length; x++) {
- %>
- <input type="radio"
name="field_<%=currentField.getID()%>" value="<%=values[x]%>">
<%=values[x]%><br/>
- <%
- }
- } else {
- if (jData.gui().isEditMode()) {
- %><span style="color:red;">Default
value is
- required for this type</span><%
- }
- }
- } else if
(ResourceBundleMarker.drawMarker(resBundleID,"checkboxes","").equals(type)) {
- if (! "".equals(defaultValue)) {
- String[] values =
defaultValue.split(":");
- for (int x=0; x<values.length; x++) {
- %>
- <input type="checkbox"
name="field_<%=currentField.getID()%>" value="<%=values[x]%>">
<%=values[x]%><br/>
- <%
- }
- } else {
- if (jData.gui().isEditMode()) {
- %><span style="color:red;">Default
value is
- required for this type</span><%
- }
- }
- } else if
(ResourceBundleMarker.drawMarker(resBundleID,"selectBox","").equals(type)) {
- if (! "".equals(defaultValue)) {
- %>
- <select
name="field_<%=currentField.getID()%>">
- <%
- String[] values =
defaultValue.split(":");
- for (int x=0; x<values.length; x++) {
- %>
- <option ><%=values[x]%></option>
- <%
- }
- %>
- </select>
- <%
- } else {
- if (jData.gui().isEditMode()) {
- %><span style="color:red;">Default
value is
- required for this type</span><%
- }
- }
- %>
-
- <%
- } else if
(ResourceBundleMarker.drawMarker(resBundleID,"submitButton","").equals(type)) {
- if ("".equals(defaultValue)){
- defaultValue = "Submit";
- }
- %>
- <input type="submit"
name="field_<%=currentField.getID()%>"
- value="<%=defaultValue%>"/>
- <%
- } else {
- %>
- <input type="text"
name="field_<%=currentField.getID()%>"
- value="<%=defaultValue%>" size="80"/>
- <%
- }
- %>
- </td>
- </tr>
- <%
- }
- %>
- </table>
- </form>
- <%
-
- jData.gui().html().drawEndActionMenu(fieldsBean , null,
- null, true,
"","jahiatemplates.Corporate_portal_templates",
- null, out);
- }
-
-
- }
- }
- jData.gui().html().drawEndActionMenu(formsBean ,
- null, null, true, "", "jahiatemplates.Corporate_portal_templates",
null, out);
-}
-%>
</td>