Example usage for org.apache.wicket Component getDefaultModelObjectAsString

List of usage examples for org.apache.wicket Component getDefaultModelObjectAsString

Introduction

In this page you can find the example usage for org.apache.wicket Component getDefaultModelObjectAsString.

Prototype

public final String getDefaultModelObjectAsString() 

Source Link

Document

Gets a model object as a string.

Usage

From source file:com.googlecode.wicket.jquery.ui.widget.progressbar.ProgressBarBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);

    this.setOption("value", component.getDefaultModelObjectAsString()); //initial value
    this.setOption("change", this.onChangeBehavior.getCallbackFunction());
}

From source file:com.googlecode.wicket.kendo.ui.widget.progressbar.ProgressBarBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);

    this.setOption("value", component.getDefaultModelObjectAsString()); // initial value
}

From source file:org.apache.syncope.client.console.pages.ReportletConfModalPage.java

License:Apache License

public ReportletConfModalPage(final AbstractReportletConf reportletConf, final ModalWindow window,
        final PageReference pageRef) {

    this.reportletConf = reportletConf;

    final Form form = new Form(FORM);
    add(form);//from   ww w  .  ja  va2s. com

    propertiesContainer = new WebMarkupContainer("container");
    propertiesContainer.setOutputMarkupId(true);
    form.add(propertiesContainer);

    name = new AjaxTextFieldPanel("name", "name", this.reportletConf == null ? new Model<String>()
            : new PropertyModel<String>(this.reportletConf, "name"));
    name.setOutputMarkupId(true);
    name.addRequiredLabel();
    form.add(name);

    final AjaxDropDownChoicePanel<String> reportletClass = new AjaxDropDownChoicePanel<String>("reportletClass",
            "reportletClass", new IModel<String>() {

                private static final long serialVersionUID = -2316468110411802130L;

                @Override
                public String getObject() {
                    return ReportletConfModalPage.this.reportletConf == null ? null
                            : ReportletConfModalPage.this.reportletConf.getClass().getName();
                }

                @Override
                public void setObject(final String object) {
                    try {
                        Class<?> reportletClass = Class.forName(object);
                        ReportletConfModalPage.this.reportletConf = (AbstractReportletConf) reportletClass
                                .newInstance();
                        propertiesContainer.replace(buildPropView());
                    } catch (Exception e) {
                        LOG.error("Cannot find or initialize {}", object, e);
                    }
                }

                @Override
                public void detach() {
                }
            });
    reportletClass.setStyleSheet("long_dynamicsize");
    reportletClass.setChoices(reportRestClient.getReportletConfClasses());
    ((DropDownChoice) reportletClass.getField()).setNullValid(true);
    reportletClass.addRequiredLabel();
    reportletClass.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = 5538299138211283825L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            ((DropDownChoice) reportletClass.getField()).setNullValid(false);
            target.add(reportletClass.getField());
            target.add(propertiesContainer);
        }
    });
    form.add(reportletClass);

    propertiesContainer.add(buildPropView());

    final AjaxButton submit = new AjaxButton(APPLY, new ResourceModel(APPLY)) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            final BeanWrapper wrapper = PropertyAccessorFactory
                    .forBeanPropertyAccess(ReportletConfModalPage.this.reportletConf);
            wrapper.setPropertyValue("name", name.getField().getInput());

            // Iterate over properties in order to find UserSearchPanel instances and manually update
            // this.reportletConf with select search criteria - this is needed because UserSearchPanel
            // does not comply with usual Wicket model paradigm.
            ReportletConfModalPage.this.propView.visitChildren(new IVisitor<Component, Void>() {

                @Override
                public void component(final Component component, final IVisit<Void> ivisit) {
                    if (component instanceof UserSearchPanel) {
                        // using component.getDefaultModelObjectAsString() to fetch field name (set above)
                        wrapper.setPropertyValue(component.getDefaultModelObjectAsString(),
                                ((UserSearchPanel) component).buildFIQL());
                    }
                }
            });

            ((ReportModalPage) pageRef.getPage())
                    .setModalReportletConf(ReportletConfModalPage.this.reportletConf);
            window.close(target);
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final Form<?> form) {
            feedbackPanel.refresh(target);
        }
    };
    form.add(submit);

    final AjaxButton cancel = new ClearIndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL), pageRef) {

        private static final long serialVersionUID = -958724007591692537L;

        @Override
        protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
            window.close(target);
        }
    };

    cancel.setDefaultFormProcessing(false);
    form.add(cancel);
}

From source file:org.artifactory.common.wicket.behavior.combobox.ComboBoxBehavior.java

License:Open Source License

@Override
public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);
    assertTagName(tag, "select");
    tag.put("dojoType", getJsClass());
    tag.put("value", component.getDefaultModelObjectAsString());
}

From source file:org.artifactory.common.wicket.behavior.combobox.history.HistoryComboBoxBehavior.java

License:Open Source License

@Override
public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);
    assertTagName(tag, "select");
    tag.put("dojoType", "artifactory.HistoryComboBox");
    tag.put("cookie", getCookieName());
    tag.put("value", component.getDefaultModelObjectAsString());
}

From source file:org.cyclop.web.panels.queryeditor.editor.EditorPanel.java

License:Apache License

private void initEditor() {
    editor = new TextArea<>("queryEditor", editorModel);
    editor.setEscapeModelStrings(false);
    add(editor);/*  ww w. j  a  v  a  2 s.  c  om*/
    editor.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            Component cmp = getComponent();
            String editorValue = cmp.getDefaultModelObjectAsString();

            ContextCqlCompletion cqlCompletion;
            if (StringUtils.isEmpty(editorValue)) {
                cqlCompletion = completionService.findInitialCompletion();
            } else {
                RequestCycle requestCycle = RequestCycle.get();
                int index = requestCycle.getRequest().getRequestParameters().getParameterValue("cursorPos")
                        .toInt();
                CqlQuery cqlQuery = new CqlQuery(CqlQueryType.UNKNOWN, editorValue);
                cqlCompletion = completionService.findCompletion(cqlQuery, index);
            }
            if (cqlCompletion.cqlCompletion.isEmpty() || cqlCompletion.equals(currentCompletion)) {
                return;
            }

            fireCompletionChanged(cqlCompletion);
            String suggestsScript = generateReplaceSuggestsJs(editorMarkupIdJq,
                    cqlCompletion.cqlCompletion.fullCompletion);
            target.appendJavaScript(suggestsScript);

            for (CompletionChangeListener list : completionChangeListeners) {
                Component refresh = list.getReferencesForRefresh();
                if (refresh == null) {
                    continue;
                }
                target.add(refresh);
            }
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.getDynamicExtraParameters()
                    .add("return {'cursorPos' : getCaretPosition(" + editorMarkupIdJs + ")}");
            super.updateAjaxAttributes(attributes);
        }
    });
}

From source file:org.geoserver.web.admin.StatusPageTest.java

License:Open Source License

@Test
public void testModuleStatusPanelVersion() {
    //Skip this test if we are excecuting from an IDE; the version is extracted from the compiled jar
    Assume.assumeFalse(//from  ww  w  . j av a  2  s  . com
            ModuleStatusImpl.class.getResource("ModuleStatusImpl.class").getProtocol().equals("file"));

    tester.assertRenderedPage(StatusPage.class);
    tester.clickLink("tabs:tabs-container:tabs:1:link", true);
    tester.assertContains("gs-main");
    Component component = tester
            .getComponentFromLastRenderedPage("tabs:panel:listViewContainer:modules:1:version");
    assertTrue(component instanceof Label);
    assertNotNull(component.getDefaultModelObjectAsString());
    assertNotEquals("", component.getDefaultModelObjectAsString().trim());
}

From source file:org.geoserver.web.wicket.WicketHierarchyPrinter.java

License:Open Source License

/**
 * Prints a single component/*from  ww  w  .ja  v  a 2  s.  c om*/
 */
private void printComponent(Component c, int level) {
    if (c instanceof Page)
        out.print(tab(level) + "PAGE_ROOT");
    else
        out.print(tab(level) + c.getId());

    if (pathDumpEnabled) {
        out.print(" " + c.getPageRelativePath());
    }

    if (classDumpEnabled) {
        String className;
        if (c.getClass().isAnonymousClass()) {
            className = c.getClass().getSuperclass().getName();
        } else {
            className = c.getClass().getName();
        }

        out.print("(" + className + ")");
    }

    if (valueDumpEnabled) {
        try {
            String value = NEWLINE.matcher(c.getDefaultModelObjectAsString()).replaceAll("\\\\n");
            out.print(" '" + value + "'");
        } catch (Exception e) {
            out.print(" 'ERROR_RETRIEVING_MODEL " + e.getMessage() + "'");
        }
    }

    out.println();
}

From source file:org.openengsb.ui.admin.sendEventPage.SendEventPageTest.java

License:Apache License

@Test
public void firstClassIsDefault_shouldCreateEditorFieldsBasedOnDefault() {
    assertThat(fieldList.size(), is(3));
    Component attributeName = fieldList.get("testProperty:row:name");
    assertThat(attributeName.getDefaultModelObjectAsString(), is("testProperty"));
}

From source file:org.openengsb.ui.admin.sendEventPage.SendEventPageTest.java

License:Apache License

@Test
public void selectNewClassInDropDown_shouldRenderNewEditorPanelThroughAjax() {
    selectEventType(1);//  w w w  .j a  v  a  2s.c  om
    fieldList = (RepeatingView) tester.getComponentFromLastRenderedPage("form:fieldContainer:fields");
    assertThat(fieldList.size(), is(2));
    Component attributeName = fieldList.get("name:row:name");
    assertThat(attributeName.getDefaultModelObjectAsString(), is("name"));
}