1 package org.jahia.views.engines.helloworld.forms; 2 3 import javax.servlet.http.HttpServletRequest ; 4 5 import org.apache.struts.action.ActionErrors; 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionMapping; 8 import org.apache.struts.action.ActionMessage; 9 import org.apache.struts.action.ActionMessages; 10 11 import org.jahia.exceptions.JahiaException; 12 import org.jahia.views.engines.*; 13 import org.jahia.views.engines.helloworld.actions.HelloAction; 14 15 19 public final class HelloForm extends ActionForm { 20 21 public String getName() { 22 return (m_name); 23 } 24 25 public void setName(String name) { 26 m_name = name; 27 } 28 29 35 public void reset(ActionMapping mapping, HttpServletRequest request) { 36 m_name = null; 37 } 38 39 49 public ActionErrors validate(ActionMapping mapping, 50 HttpServletRequest request) { 51 ActionErrors errors = new ActionErrors(); 52 53 JahiaEngineCommonDataInterface jahiaEngineCommonData = 54 (JahiaEngineCommonDataInterface)request.getAttribute(JahiaEngineCommonData.JAHIA_ENGINE_COMMON_DATA); 55 try { 56 if (jahiaEngineCommonData == null) { 57 jahiaEngineCommonData = new JahiaEngineCommonData(request); 58 jahiaEngineCommonData.setEngineTitle(HelloAction.ENGINE_NAME); 59 request.setAttribute(JahiaEngineCommonData. 60 JAHIA_ENGINE_COMMON_DATA, 61 jahiaEngineCommonData); 62 } 63 } catch ( JahiaException je ){ 64 errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("error.engineCommonData.exception")); 65 } 66 67 if( m_name == null || m_name.length()==0 ){ 68 errors.add("name",new ActionMessage("error.name.required")); 69 } 70 return (errors); 71 } 72 73 74 75 private String m_name = null; 76 } 77 78 | Popular Tags |