[opencms-dev] org.opencms.frontend.templateone.form module improvement

N ngds at mail.ru
Sun May 1 14:22:47 CEST 2005


Dear All,

Current org.opencms.frontend.templateone.form module implementation lacks ability to keep the XML form file apart from the page that displays the form. Sometimes this feature is necessary.

I suggest the following changes to the module implementation:

1. In CmsForm class

1.1 set the class class constructors to the following:

    public CmsForm(CmsJspActionElement jsp, CmsMessages messages, boolean initial) throws Exception {    
        
        init(jsp, messages, initial, null);
    }

    public CmsForm(CmsJspActionElement jsp, CmsMessages messages, boolean initial, String formContentsUri) throws Exception {    
        
        init(jsp, messages, initial, formContentsUri);
    }

1.2 and use the following init method implementation:

    public void init(CmsJspActionElement jsp, CmsMessages messages, boolean initial, String formContentsUri) throws Exception {
        
        // read the form configuration file from VFS
        CmsFile file = jsp.getCmsObject().readFile((formContentsUri != null) ? formContentsUri : jsp.getRequestContext().getUri());
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(jsp.getCmsObject(), file);
        
        // get current Locale
        Locale locale = jsp.getRequestContext().getLocale();
        
        // init member variables
        initMembers();
        
        // initialize general form configuration
        initFormGlobalConfiguration(content, jsp.getCmsObject(), locale, messages);
        
        // initialize the form input fields
        initInputFields(content, jsp, locale, messages, initial);
    }

2. In CmsFormHandler class add the following constructor:

    public CmsFormHandler(PageContext context, HttpServletRequest req, HttpServletResponse res, String formContentsUri) throws Exception {
        super(context, req, res);
        initFormHandler(context, req, res);
        setFormConfiguration(new CmsForm(this, getMessages(), isInitial(), formContentsUri));
    }


Best regards
Nikolay




More information about the opencms-dev mailing list