How do we repopulate controls when validation fails

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Code Block
xml
titleInput.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:form>
<s:select
   tooltip="Choose Your Favorite Language"
   label="Favorite Language"
   list="languages"
   name="language"
   listKey="key"
   listValue="description"
   emptyOption="true"
   headerKey="None"
   headerValue="None"/>
<s:submit>
</form>
Code Block
java
title"Input.java (prepare)
    public String prepare() {
        languages.add(new Language("EnglishKey", "English Language"));
        languages.add(new Language("FrenchKey", "French Language"));
        languages.add(new Language("SpanishKey", "Spanish Language"));
        return SUCCESS;
    }

    List languages = new ArrayList();
    public List getLanguages() {
        return languages;
    }

    String language;
    public void setLanguage(String value) {
        language = value;
    }
    public String getLanguage() {
        return language;
    }

    public static class Language {

        public Language(String key, String description) {
            this.key = key;
            this.description = description;
        }

        String key;
        public String getKey() {
            return key;
        }

        String description;
        public String getDescription() {
            return description;
        }
    }
 }

(tick) If a custom stack is being used, be sure to put the Prepare Interceptor before the Validation Interceptor.

...