This is in one of our Wicket 1.4.7 apps that we have not converted yet.  The
problem does not happen in localhost test environments, but does happen on
the server.  Moreover, the problem only happens when a data condition causes
a particular panel to be visible.

When this panel is visible (and I pick that because it is the only major
difference between it working and failing), the page does not submit.  I hit
the submit button, and rather than advancing to the next page, the current
page redisplays with no validation errors displayed.  

Loig statements at the top of every event do not fire.  Log statements at
the top of the validate methods of the three validators applied to the form
do not fire.

The panel itself seems fairly nondescript:
        private void buildEDocPanel() {
                WebMarkupContainer wmc = new WebMarkupContainer("eDocsWrapper");
                DocTypeSelect docTypes = new DocTypeSelect("eDocTypes",
model.geteDocTypes()) {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public List<FilterValue> loadDocumentTypes() {
                                return 
lookupService.fetchFilterValuesByFilterName("Document Type");
//Document Type
                        }
                };
                form.add(wmc);
                wmc.add(docTypes);
        
wmc.setVisible(model.getApplicationCode().equals(UMCConstants.APPL_EDOCS));
        }

DocTypeSelect is a custom panel that implements a wizard-y control where one
side has a master list and you pick which ones to add to the right side's
list with add/remove buttons in the middle.  The code for this panel is
below.  Based on the log, the onAddSelected method and onSelectionChange
method fire, but both of those are BEFORE the page submit.

The HTML for the submit button is:
        <input type="submit" class="submit btnsubmit" wicket:id="nextBtn"
onclick="document.ignoreDirty=true;return true;" value="Step 3: Review
&gt;">

The onclick is for a "are you sure you want to leave since you have made
changes" kind of warning in javascript.  It doesn't interfere in localhost
or if the panel is not visible, and when it prevent departure, the page
wouldn't reload, so i am mostly sure that isn't the problem, but I present
that it is an input type submit since that has sometimes made a difference
during my experience with wicket.


public abstract class DocTypeSelect  extends Panel {
        private static final long serialVersionUID = 1L;
        private static Logger log = Logger.getLogger(DocTypeSelect.class);
        private List<FilterValue> selected;
        private ListMultipleChoice<FilterValue> ddAvailable;
        private ListMultipleChoice<FilterValue> ddSelected;
        
        public DocTypeSelect(String id, List<FilterValue> selectedDocTypes) {
                super(id);
                selected = selectedDocTypes;
                init();
        }
        
        private void init() {
                buildLeftSide();
                buildCenter();
                buildRightSide();
        }
        
        public abstract List<FilterValue> loadDocumentTypes();
        public void onSelectionChange(AjaxRequestTarget target, 
List<FilterValue>
selected) {
                log.debug("onSelectionChange()");
        }

        @SuppressWarnings({ "unchecked", "rawtypes" })
        private void buildLeftSide() {
                List<FilterValue> docTypes = loadDocumentTypes();
                ddAvailable = new 
ListMultipleChoice<FilterValue>("docTypesAvailable", 
                                new Model(new ArrayList<FilterValue>()),
                                docTypes, 
                                new IChoiceRenderer<FilterValue>() {
                                        private static final long 
serialVersionUID = 1L;
                                        @Override
                                        public Object 
getDisplayValue(FilterValue arg0) {
                                                return 
arg0.getFilterValueDecode();
                                        }
                                        @Override
                                        public String getIdValue(FilterValue 
arg0, int arg1) {
                                                return arg0.getFilterValue();
                                        }
                                });
                add(ddAvailable);
        }

        
        private void buildCenter() {
                add(new AjaxButton("addSelected") {
                        private static final long serialVersionUID = 1L;

                        @SuppressWarnings({ "rawtypes" })
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form 
form) {
                                onAddSelected(target);
                        }
                }.setDefaultFormProcessing(false));
                
                add(new AjaxButton("addAll") {
                        private static final long serialVersionUID = 1L;

                        @SuppressWarnings({ "rawtypes" })
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form 
form) {
                                onAddAll(target);
                        }
                }.setDefaultFormProcessing(false));
                
                add(new AjaxButton("removeSelected") {
                        private static final long serialVersionUID = 1L;
                        @SuppressWarnings({ "rawtypes" })
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form 
form) {
                                onRemoveSelected(target);
                        }
                }.setDefaultFormProcessing(false));
                
                add(new AjaxButton("removeAll") {
                        private static final long serialVersionUID = 1L;
                        @SuppressWarnings("rawtypes")
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form 
form) {
                                onRemoveAll(target);
                        }
                }.setDefaultFormProcessing(false));
        }
        
        @SuppressWarnings("unchecked")
        private void onAddAll(AjaxRequestTarget target) {
                log.debug("onAddAll");
                List<FilterValue> toMove = (List<FilterValue>) 
ddAvailable.getChoices();
                mergeUniquely(toMove);
                ddSelected.setChoices(selected);
                target.addComponent(ddSelected);
                onSelectionChange(target, selected);
        }
        @SuppressWarnings("unchecked")
        private void onAddSelected(AjaxRequestTarget target) {
                log.debug("onAddSelected");
                if(ddAvailable.getInput() != null) {
                        List<FilterValue> toMove = new ArrayList<FilterValue>();
                        List<FilterValue> choices = (List<FilterValue>) 
ddAvailable.getChoices();
                        String[] positional = ddAvailable.getInputAsArray();
                        for(String s:positional) {
                                for(FilterValue v:choices) {
                                        if(v.getFilterValue().equals(s))
                                                toMove.add(v);
                                }
                        }
                        mergeUniquely(toMove);
                        ddSelected.setChoices(selected);
                        target.addComponent(ddSelected);
                        onSelectionChange(target, selected);
                }
        }       
        private void onRemoveSelected(AjaxRequestTarget target) {
                log.debug("onRemoveSelected");
                if(ddSelected.getInputAsArray() != null) {
                        for(String indexToRemove:ddSelected.getInputAsArray()) {
                                FilterValue rmv = null;
                                for(FilterValue v:selected) {
                                        
if(v.getFilterValue().equals(indexToRemove)) {
                                                rmv = v;
                                                break;
                                        }
                                }
                                selected.remove(rmv);
                        }
                        target.addComponent(ddSelected);
                        onSelectionChange(target, selected);
                }
        }
        private void onRemoveAll(AjaxRequestTarget target) {
                log.debug("onRemoveAll");
                selected.clear();
                target.addComponent(ddSelected);
                onSelectionChange(target, selected);
        }
        
        @SuppressWarnings({ "unchecked", "rawtypes" })
        private void mergeUniquely(List<FilterValue> list) {
                HashSet<FilterValue> uniqueList = new HashSet<FilterValue>();
                uniqueList.addAll(list);
                uniqueList.addAll(selected);
                selected.clear();
                selected.addAll(uniqueList);
                Collections.sort(selected, new Comparator() {
                        @Override
                        public int compare(Object object1, Object object2) {
                                return
((FilterValue)object1).getFilterValueDecode().compareTo(((FilterValue)object2).getFilterValueDecode());
                        }
                });
        }
        
        @SuppressWarnings({ "unchecked", "rawtypes" })
        private void buildRightSide() {
                ArrayList<FilterValue> choices = new ArrayList<FilterValue>();
                choices.addAll(selected);
                ddSelected = new 
ListMultipleChoice<FilterValue>("docTypesSelected", 
                                new Model(new ArrayList<FilterValue>()),
                                choices, 
                                new IChoiceRenderer<FilterValue>() {
                                        private static final long 
serialVersionUID = 1L;
                                        @Override
                                        public Object 
getDisplayValue(FilterValue arg0) {
                                                return 
arg0.getFilterValueDecode();
                                        }
                                        @Override
                                        public String getIdValue(FilterValue 
arg0, int arg1) {
                                                return arg0.getFilterValue();
                                        }
                });
                ddSelected.setMarkupId("docSel2");
                ddSelected.setOutputMarkupId(true);
                add(ddSelected);
        }
}




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/1-4-7-app-form-does-not-submit-on-server-when-panel-is-not-visible-tp4663114.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to