Repository: struts-examples Updated Branches: refs/heads/develop c73eae6a2 -> 111b1a7c3
http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close-validate.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close-validate.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close-validate.ftl new file mode 100644 index 0000000..f129156 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close-validate.ftl @@ -0,0 +1,158 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#-- +START SNIPPET: supported-validators +Only the following validators are supported: +* required validator +* requiredstring validator +* stringlength validator +* regex validator +* email validator +* url validator +* int validator +* double validator +END SNIPPET: supported-validators +--> +<#if ((parameters.validate!false == true) && (parameters.performValidation!false == true))> +<script type="text/javascript"> + function validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}() { + <#-- + In case of multiselect fields return only the first value. + --> + var getFieldValue = function(field) { + var type = field.type ? field.type : field[0].type; + if (type == 'select-one' || type == 'select-multiple') { + return (field.selectedIndex == -1 ? "" : field.options[field.selectedIndex].value); + } else if (type == 'checkbox' || type == 'radio') { + if (!field.length) { + field = [field]; + } + for (var i = 0; i < field.length; i++) { + if (field[i].checked) { + return field[i].value; + } + } + return ""; + } + return field.value; + } + form = document.getElementById("${parameters.id}"); + clearErrorMessages(form); + clearErrorLabels(form); + + var errors = false; + var continueValidation = true; + <#list parameters.tagNames as tagName> + <#list tag.getValidators("${tagName}") as aValidator> + // field name: ${aValidator.fieldName} + // validator name: ${aValidator.validatorType} + if (form.elements['${aValidator.fieldName}']) { + field = form.elements['${aValidator.fieldName}']; + <#if aValidator.validatorType = "field-visitor"> + <#assign validator = aValidator.fieldValidator > + //visitor validator switched to: ${validator.validatorType} + <#else> + <#assign validator = aValidator > + </#if> + + var error = "${validator.getMessage(action)?js_string}"; + var fieldValue = getFieldValue(field); + + <#if validator.validatorType = "required"> + if (fieldValue == "") { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + <#elseif validator.validatorType = "requiredstring"> + if (continueValidation && fieldValue != null && (fieldValue == "" || fieldValue.replace(/^\s+|\s+$/g,"").length == 0)) { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + <#elseif validator.validatorType = "stringlength"> + if (continueValidation && fieldValue != null) { + var value = fieldValue; + <#if validator.trim> + //trim field value + while (value.substring(0,1) == ' ') + value = value.substring(1, value.length); + while (value.substring(value.length-1, value.length) == ' ') + value = value.substring(0, value.length-1); + </#if> + if ((${validator.minLength?c} > -1 && value.length < ${validator.minLength?c}) || + (${validator.maxLength?c} > -1 && value.length > ${validator.maxLength?c})) { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + } + <#elseif validator.validatorType = "regex"> + if (continueValidation && fieldValue != null && !fieldValue.match("${validator.regex?js_string}")) { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + <#elseif validator.validatorType = "email"> + if (continueValidation && fieldValue != null && fieldValue.length > 0 && fieldValue.match("${validator.regex?js_string}")==null) { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + <#elseif validator.validatorType = "url"> + if (continueValidation && fieldValue != null && fieldValue.length > 0 && fieldValue.match("/${validator.urlRegex?js_string}/i")==null) { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + <#elseif validator.validatorType = "int" || validator.validatorType = "short"> + if (continueValidation && fieldValue != null) { + if (<#if validator.min??>parseInt(fieldValue) < + ${validator.min?c}<#else>false</#if> || + <#if validator.max??>parseInt(fieldValue) > + ${validator.max?c}<#else>false</#if>) { + addError(field, error); + errors = true; + <#if validator.shortCircuit>continueValidation = false;</#if> + } + } + <#elseif validator.validatorType = "double"> + if (continueValidation && fieldValue != null) { + var value = parseFloat(fieldValue); + if (<#if validator.minInclusive??>value < ${validator.minInclusive?c}<#else>false</#if> || + <#if validator.maxInclusive??>value > ${validator.maxInclusive?c}<#else>false</#if> || + <#if validator.minExclusive??>value <= ${validator.minExclusive?c}<#else>false</#if> || + <#if validator.maxExclusive??>value >= ${validator.maxExclusive?c}<#else>false</#if>) { + addError(field, error); + errors = true; + } + } + </#if> + } + </#list> + </#list> + + return !errors; + } +</script> +</#if> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close.ftl new file mode 100644 index 0000000..d783454 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-close.ftl @@ -0,0 +1,35 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/control-close.ftl" /> +<#include "/${parameters.templateDir}/simple/form-close.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/form-close-validate.ftl" /> +<#if parameters.focusElement?if_exists != ""> +<script type="text/javascript"> + StrutsUtils.addOnLoad(function() { + var element = document.getElementById("${parameters.focusElement?html}"); + if(element) { + element.focus(); + } + }); +</script> +</#if> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-validate.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-validate.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-validate.ftl new file mode 100644 index 0000000..6597f4e --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form-validate.ftl @@ -0,0 +1,31 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#if parameters.validate?default(false) == true> + <script type="text/javascript" src="${base}/struts/xhtml/validation.js"></script> + <script type="text/javascript" src="${base}/struts/utils.js"></script> + <#if parameters.onsubmit??> + ${tag.addParameter('onsubmit', "${parameters.onsubmit}; return validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}();")} + <#else> + ${tag.addParameter('onsubmit', "return validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}();")} + </#if> +</#if> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/form.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/form.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form.ftl new file mode 100644 index 0000000..5a686dd --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/form.ftl @@ -0,0 +1,33 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/form-validate.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/form-common.ftl" /> +<#if (parameters.validate?default(false))> + onreset="${parameters.onreset?default('clearErrorMessages(this);clearErrorLabels(this);')}" +<#else> + <#if parameters.onreset??> + onreset="${parameters.onreset?html}" + </#if> +</#if> +> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/control.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/head.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/head.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/head.ftl new file mode 100644 index 0000000..e8a8fb8 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/head.ftl @@ -0,0 +1,24 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<link rel="stylesheet" href="<@s.url value='/struts/xhtml/styles.css' includeParams='none' encode='false' />" type="text/css"/> +<#include "/${parameters.templateDir}/simple/head.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/hidden.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/hidden.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/hidden.ftl new file mode 100644 index 0000000..92881ab --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/hidden.ftl @@ -0,0 +1,27 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<tr style="display:none;"> + <td colspan="2"> + <#include "/${parameters.templateDir}/simple/hidden.ftl" /> + </td> +</tr> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/inputtransferselect.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/inputtransferselect.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/inputtransferselect.ftl new file mode 100644 index 0000000..f25a6ab --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/inputtransferselect.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/inputtransferselect.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /><#nt/> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/label.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/label.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/label.ftl new file mode 100644 index 0000000..8faf8d6 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/label.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/label.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/optiontransferselect.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/optiontransferselect.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/optiontransferselect.ftl new file mode 100644 index 0000000..e1cd440 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/optiontransferselect.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/optiontransferselect.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /><#nt/> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/password.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/password.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/password.ftl new file mode 100644 index 0000000..202da51 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/password.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/password.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/radiomap.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/radiomap.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/radiomap.ftl new file mode 100644 index 0000000..008de45 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/radiomap.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/radiomap.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /><#nt/> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/reset.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/reset.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/reset.ftl new file mode 100644 index 0000000..8e6e2b5 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/reset.ftl @@ -0,0 +1,31 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<tr> + <td colspan="2"><div <#rt/> +<#if parameters.align??> + align="${parameters.align?html}"<#t/> +</#if> +><#t/> +<#include "/${parameters.templateDir}/simple/reset.ftl" /> +</div><#t/> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/select.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/select.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/select.ftl new file mode 100644 index 0000000..9d07046 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/select.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/select.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/styles.css ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/styles.css b/themes_override/src/main/webapp/WEB-INF/template/xhtml/styles.css new file mode 100644 index 0000000..dd54904 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/styles.css @@ -0,0 +1,29 @@ +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +.wwFormTable {} +.label {font-style:italic; } +.errorLabel {font-style:italic; color:red; } +.errorMessage {font-weight:bold; color:red; } +.checkboxLabel {} +.checkboxErrorLabel {color:red; } +.required {color:red;} +.tdLabel {text-align:right; vertical-align:top; } http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit-close.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit-close.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit-close.ftl new file mode 100644 index 0000000..faa551c --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit-close.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/simple/submit-close.ftl" /> +</div><#t/> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit.ftl new file mode 100644 index 0000000..7b82921 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/submit.ftl @@ -0,0 +1,29 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<tr> + <td colspan="2"><div <#rt/> +<#if parameters.align??> + align="${parameters.align?html}"<#t/> +</#if> +><#t/> +<#include "/${parameters.templateDir}/simple/submit.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/text.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/text.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/text.ftl new file mode 100644 index 0000000..53f1647 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/text.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/text.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/textarea.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/textarea.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/textarea.ftl new file mode 100644 index 0000000..46f77d9 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/textarea.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/textarea.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/theme.properties ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/theme.properties b/themes_override/src/main/webapp/WEB-INF/template/xhtml/theme.properties new file mode 100644 index 0000000..84dc155 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/theme.properties @@ -0,0 +1,21 @@ +# +# $Id$ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +parent = simple http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/tooltip.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/tooltip.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/tooltip.ftl new file mode 100644 index 0000000..74938a8 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/tooltip.ftl @@ -0,0 +1,41 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#if parameters.tooltip??><#t/> + <img + <#if parameters.tooltipIconPath??><#t/> + src='<@s.url value="${parameters.tooltipIconPath}" includeParams="none" encode="false" />' + <#else><#t/> + src='<@s.url value="/struts/tooltip.gif" includeParams="none" encode="false" />' + </#if><#t/> + <#if parameters.jsTooltipEnabled?default('false') == 'true'> + onmouseover="domTT_activate(this, event, 'content', '${parameters.tooltip}'<#t/> + <#if parameters.tooltipDelay??><#t/> + <#t/>,'delay', '${parameters.tooltipDelay}'<#t/> + </#if><#t/> + <#t/>,'styleClass', '${parameters.tooltipCssClass?default("StrutsTTClassic")}'<#t/> + <#t/>)" /> + <#else> + title="${parameters.tooltip?html}" + alt="${parameters.tooltip?html}" /> + </#if> +</#if><#t/> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/updownselect.ftl ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/updownselect.ftl b/themes_override/src/main/webapp/WEB-INF/template/xhtml/updownselect.ftl new file mode 100644 index 0000000..bd575f7 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/updownselect.ftl @@ -0,0 +1,25 @@ +<#-- +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /> +<#include "/${parameters.templateDir}/simple/updownselect.ftl" /> +<#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /><#nt/> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/template/xhtml/validation.js ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/template/xhtml/validation.js b/themes_override/src/main/webapp/WEB-INF/template/xhtml/validation.js new file mode 100644 index 0000000..e63751b --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/template/xhtml/validation.js @@ -0,0 +1,139 @@ +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function clearErrorMessagesXHTML(form) { + + // get field table + var table, i, r; + for (i = 0; i < form.childNodes.length; i++) { + if (form.childNodes[i].tagName !== undefined && form.childNodes[i].tagName.toLowerCase() === 'table') { + table = form.childNodes[i]; + break; + } + } + + if (table === null) { + return; + } + + // clear out any rows with an "errorFor" attribute + var rows = table.rows; + if (rows === null){ + return; + } + + var rowsToDelete = []; + for(i = 0; i < rows.length; i++) { + r = rows[i]; + // allow blank errorFor values on dojo markup + if (r.getAttribute("errorFor") !== null) { + rowsToDelete.push(r); + } + } + + // now delete the rows + for (i = 0; i < rowsToDelete.length; i++) { + r = rowsToDelete[i]; + table.deleteRow(r.rowIndex); + //table.removeChild(rowsToDelete[i]); + } +} + +function clearErrorMessages(form) { + clearErrorMessagesXHTML(form); +} + +function clearErrorLabelsXHTML(form) { + // set all labels back to the normal class + var i, elements = form.elements; + for (i = 0; i < elements.length; i++) { + + var parentEl = elements[i]; + // search for the parent table row, abort if the form is reached + // the form may contain "non-wrapped" inputs inserted by Dojo + while (parentEl.nodeName.toUpperCase() !== "TR" && parentEl.nodeName.toUpperCase() !== "FORM") { + parentEl = parentEl.parentNode; + } + if (parentEl.nodeName.toUpperCase() === "FORM") { + parentEl = null; + } + + //if labelposition is 'top' the label is on the row above + if(parentEl && parentEl.cells) { + var labelRow = parentEl.cells.length > 1 ? parentEl : StrutsUtils.previousElement(parentEl, "tr"); + if (labelRow) { + var cells = labelRow.cells; + if (cells && cells.length >= 1) { + var label = cells[0].getElementsByTagName("label")[0]; + if (label) { + label.setAttribute("class", "label"); + label.setAttribute("className", "label"); //ie hack cause ie does not support setAttribute + } + } + } + } + } + +} + +function clearErrorLabels(form) { + clearErrorLabelsXHTML(form); +} + +function addErrorXHTML(e, errorText) { + try { + var row = (e.type ? e : e[0]); + while(row.nodeName.toUpperCase() !== "TR") { + row = row.parentNode; + } + var table = row.parentNode; + var error = document.createTextNode(errorText); + var tr = document.createElement("tr"); + var td = document.createElement("td"); + var span = document.createElement("span"); + td.align = "center"; + td.valign = "top"; + td.colSpan = 2; + span.setAttribute("class", "errorMessage"); + span.setAttribute("className", "errorMessage"); //ie hack cause ie does not support setAttribute + span.appendChild(error); + td.appendChild(span); + tr.appendChild(td); + tr.setAttribute("errorFor", e.id); + table.insertBefore(tr, row); + + // update the label too + //if labelposition is 'top' the label is on the row above + var labelRow = row.cells.length > 1 ? row : StrutsUtils.previousElement(tr, "tr"); + var label = labelRow.cells[0].getElementsByTagName("label")[0]; + if (label) { + label.setAttribute("class", "errorLabel"); + label.setAttribute("className", "errorLabel"); //ie hack cause ie does not support setAttribute + } + } catch (err) { + alert(err); + } +} + +function addError(e, errorText) { + addErrorXHTML(e, errorText); +} + http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/WEB-INF/web.xml b/themes_override/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..a5fcf75 --- /dev/null +++ b/themes_override/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> +<display-name>Themes Struts 2</display-name> + <welcome-file-list> + <welcome-file>index.jsp</welcome-file> + </welcome-file-list> + + + <filter> + <filter-name>struts2</filter-name> + <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>struts2</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + +</web-app> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/edit.jsp ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/edit.jsp b/themes_override/src/main/webapp/edit.jsp new file mode 100644 index 0000000..bb1ef76 --- /dev/null +++ b/themes_override/src/main/webapp/edit.jsp @@ -0,0 +1,29 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="s" uri="/struts-tags" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<s:head /> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Struts 2 Form Tags - Edit Person</title> + +</head> +<body> +<h1>Update Information</h1> + +<p>Use the form below to edit your information.</p> + +<s:form action="save" method="post"> +<s:textfield key="personBean.firstName" /> +<s:textfield key="personBean.lastName" /> +<s:select key="personBean.sport" list="sports" /> +<s:radio key="personBean.gender" list="genders" /> +<s:select key="personBean.residency" list="states" listKey="stateAbbr" listValue="stateName" /> +<s:checkbox key="personBean.over21" /> +<s:checkboxlist key="personBean.carModels" list="carModelsAvailable" /> +<s:submit key="submit" /> +</s:form> + +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/index.jsp ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/index.jsp b/themes_override/src/main/webapp/index.jsp new file mode 100644 index 0000000..88209d8 --- /dev/null +++ b/themes_override/src/main/webapp/index.jsp @@ -0,0 +1,16 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="s" uri="/struts-tags" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Struts 2 Form Tags - Welcome</title> +</head> +<body> +<h1>Welcome To Struts 2!</h1> + +<p><a href='<s:url action="edit" />' >Edit your information</a></p> + +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-examples/blob/111b1a7c/themes_override/src/main/webapp/thankyou.jsp ---------------------------------------------------------------------- diff --git a/themes_override/src/main/webapp/thankyou.jsp b/themes_override/src/main/webapp/thankyou.jsp new file mode 100644 index 0000000..7c268ef --- /dev/null +++ b/themes_override/src/main/webapp/thankyou.jsp @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="s" uri="/struts-tags" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Update Successful</title> +</head> +<body> + +<h1>Updated Information</h1> + + +<p>Your information: <s:property value="personBean" /> </p> + +<p><a href="<s:url action='index' />" >Return to home page</a>.</p> + +</body> +</html> \ No newline at end of file