@Override protected void onConfigure() { super.onConfigure(); // set all components visible Components.show(help, label, feedback); // clear feedback message and current state stateClassName.setObject(""); feedback.setDefaultModelObject(""); final List<FormComponent<?>> formComponents = findFormComponents(); for (final FormComponent<?> fc : formComponents) { final FeedbackMessages messages = fc.getFeedbackMessages(); if (!messages.isEmpty()) { final FeedbackMessage worstMessage = getWorstMessage(messages); worstMessage.markRendered(); stateClassName.setObject(toClassName(worstMessage)); feedback.setDefaultModelObject(worstMessage.getMessage()); break; // render worst message of first found child component with feedback message } } Components.hideIfModelIsEmpty(help); Components.hideIfModelIsEmpty(label); Components.hideIfModelIsEmpty(feedback); }
private List<IColumn<Foo, String>> createColumns() { List<IColumn<Foo, String>> columns = new ArrayList<IColumn<Foo, String>>(); columns.add(new PropertyColumn<Foo, String>(Model.of("ID"), "id")); columns.add(new TreeColumn<Foo, String>(Model.of("Tree"))); columns.add( new AbstractColumn<Foo, String>(Model.of("Depth")) { private static final long serialVersionUID = 1L; @Override public void populateItem( Item<ICellPopulator<Foo>> cellItem, String componentId, IModel<Foo> rowModel) { NodeModel<Foo> nodeModel = (NodeModel<Foo>) rowModel; cellItem.add(new Label(componentId, "" + nodeModel.getDepth())); } @Override public String getCssClass() { return "number"; } }); columns.add(new PropertyColumn<Foo, String>(Model.of("Bar"), "bar")); columns.add(new PropertyColumn<Foo, String>(Model.of("Baz"), "baz")); return columns; }
/** * Construct. * * @param id the wicket component id */ public FormGroup(final String id, final IModel<String> label, final IModel<String> help) { super(id, Model.of("")); this.labelModel = label; this.helpModel = help; stateClassName = Model.of(""); }
public TelefoneUsuarioPanel(String id) { super(id); add(new TextField<String>("telefone", Model.of(""))); add(new Button("addTelefone", Model.of(""))); add(new Button("removeTelefone", Model.of(""))); }
/** * Returns a list of columns for the repository list * * @return Columns list */ private List<IColumn<ImportableRemoteRepo>> getColumns() { List<IColumn<ImportableRemoteRepo>> columns = Lists.newArrayList(); columns.add( new SelectAllCheckboxColumn<ImportableRemoteRepo>("", "selected", null) { @Override protected void onUpdate( FormComponent checkbox, ImportableRemoteRepo rowObject, boolean value, AjaxRequestTarget target) { super.onUpdate(checkbox, rowObject, value, target); // On each update, refresh import button to customize the warning messages of the call // decorator target.add(importButton); } @Override protected void onSelectAllUpdate(AjaxRequestTarget target) { target.add(importButton); } }); columns.add(new KeyTextFieldColumn()); columns.add( new TooltipLabelColumn<ImportableRemoteRepo>(Model.of("URL"), "repoUrl", "repoUrl", 50)); columns.add( new TooltipLabelColumn<ImportableRemoteRepo>( Model.of("Description"), "repoDescription", "repoDescription", 25)); return columns; }
/** * Adds a SimpleAttributeModifier("title", ...) to the given component. * * @param component * @param title * @param text * @see #createTooltip(String, String) * @see #setStyleHasTooltip(Component) */ public static Component addTooltip( final Component component, final String title, final String text, final boolean rightAlignment) { return addTooltip(component, Model.of(title), Model.of(text), rightAlignment); }
private void importReportFromStreamPerformed(AjaxRequestTarget target) { String xml = xmlEditorModel.getObject(); if (StringUtils.isEmpty(xml)) { error(getString("PageNewReport.message.emptyXml")); target.add(getFeedbackPanel()); return; } OperationResult result = new OperationResult(OPERATION_IMPORT_REPORT_XML); InputStream stream = null; try { setResponsePage(new PageReport(new ReportDto(Base64.encodeBase64(xml.getBytes())))); } catch (Exception ex) { result.recordFatalError("Couldn't import object.", ex); LoggingUtils.logException(LOGGER, "Error occured during xml import", ex); } finally { if (stream != null) { IOUtils.closeQuietly(stream); } } if (result.isSuccess()) { xmlEditorModel.setObject(null); } showResult(result); target.add(getFeedbackPanel()); }
public AddressPanel(final String id, final IModel<HomeAddress> model) { super(id, model); setOutputMarkupId(true); add( streetNumberPanel = newStreetNumberPanel("streetNumberPanel", Model.of("Street / number:"))); add(zipcodeCityPanel = newZipcodeCityPanel("zipcodeCityPanel", Model.of("Zip / City:"))); }
public TestCaptchaRatingPanel(String id) { super( id, Model.of(5), Model.of(5), Model.of(5), Model.of(Boolean.FALSE), true, new BubblePanel("id")); }
/** Constructor. */ public CodeBehavior() { super(); lineNumbers = Model.of(false); cssClassNameModel = Model.of(""); language = Model.of(Language.DYNAMIC); from = Model.of(0); cssClassNameAppender = new CssClassNameAppender(cssClassNameModel); }
private void setFormFieldsFromQuestion(Question question) { Answer.AnswerType aType = question.getAnswerType(); questionTitleField.setModelObject(question.getTitle()); questionPromptField.setModelObject(question.getPrompt()); questionPrefaceField.setModelObject(question.getPreface()); questionCitationField.setModelObject(question.getCitation()); questionResponseTypeModel.setObject(question.getAnswerType()); Long answerReasonId = question.getAnswerReasonExpressionId(); questionAnswerReasonModel.setObject( answerReasonId == null ? answerAlways : Expressions.get(answerReasonId)); String msg = "Asking style in setFormFields: " + askingStyleModel.getObject(); askingStyleModel.setObject(question.getAskingStyleList()); msg += " -> " + askingStyleModel.getObject() + " (question had " + question.getAskingStyleList() + ")"; // throw new RuntimeException(msg); // questionUseIfField.setModelObject(question.getUseIfExpression()); otherSpecifyCheckBox.setModelObject(question.getOtherSpecify()); noneButtonCheckBox.setModelObject(question.getNoneButton()); if (aType == Answer.AnswerType.NUMERICAL) { numericLimitsPanel.setVisible(true); } else if (aType == Answer.AnswerType.MULTIPLE_SELECTION) { multipleSelectionLimitsPanel.setVisible(true); noneButtonLabel.setVisible(true); noneButtonCheckBox.setVisible(true); } if (aType == Answer.AnswerType.SELECTION || aType == Answer.AnswerType.MULTIPLE_SELECTION) { otherSpecifyLabel.setVisible(true); otherSpecifyCheckBox.setVisible(true); } else { otherSpecifyLabel.setVisible(false); otherSpecifyCheckBox.setVisible(false); } if (aType == Answer.AnswerType.DATE || aType == Answer.AnswerType.TIME_SPAN) { timeUnitsPanel.setVisible(true); } else { timeUnitsPanel.setVisible(false); } numericLimitsPanel.setMinLimitType(question.getMinLimitType()); numericLimitsPanel.setMinLiteral(question.getMinLiteral()); numericLimitsPanel.setMinPrevQues(question.getMinPrevQues()); numericLimitsPanel.setMaxLimitType(question.getMaxLimitType()); numericLimitsPanel.setMaxLiteral(question.getMaxLiteral()); numericLimitsPanel.setMaxPrevQues(question.getMaxPrevQues()); multipleSelectionLimitsPanel.setMinCheckableBoxes(question.getMinCheckableBoxes()); multipleSelectionLimitsPanel.setMaxCheckableBoxes(question.getMaxCheckableBoxes()); listLimitsPanel.setQuestion(question); }
public GlossResultsSeparatedPanel(String id, IModel<List<SegmentedWord>> model) { super(id, model); Form<List<SegmentedWord>> form = new Form<>("form", model); add(form); Border textBorder = new HeaderPanel( "text", hid -> new HeaderButtonTitlePanel( hid, Model.of("Text"), bid -> new EditButton(bid, new ResourceModel("label.edit")).setSize(Size.Small))); form.add(textBorder); textBorder.add( new ListView<>( "text", model, item -> { ExternalLink link = new ExternalLink( "word", Model.of("#def_link_" + item.getIndex()), new LambdaModel<>( item.getModel(), new OptionalFunction<>(SegmentedWord.FUNCTION_TEXT))); link.add( new EnabledModelBehavior( new SupplierModel<>(() -> item.getModelObject().hasDefinition()))); link.setMarkupId("word_link_" + item.getIndex()); item.add(link); })); Border defBorder = new HeaderPanel("defs", Model.of("Definitions")); form.add(defBorder); defBorder.add( new ListView<>( "defs", model, item -> item.add( new WordPartsListPanel( "def", item.getModel(), new SupplierModel<>(() -> "#word_link_" + item.getIndex()))) .setMarkupId("def_link_" + item.getIndex()) .add( new VisibleModelBehavior( new SupplierModel<>(() -> item.getModelObject().hasDefinition()))))); }
protected void onSubmitForm() { String valueName = HtmlSanitizer.sanitize(modelName.getObject()); Collection<UserRoles> newRoles = modelRoles.getObject(); _user.setName(valueName); String password = modelPassword1.getObject(); try { facade.createIdentity(selectedProvider, valueName, password, null, newRoles); setResponsePage(UserOverviewPage.class); } catch (UserExistsException e) { error(e.getMessage()); } }
/** * Uses "jiraSupportTooltipImage" as component id. * * @param parent only needed for localization * @param id * @return IconPanel which is invisible if JIRA isn't configured. */ public static IconPanel getJIRASupportTooltipIcon(final Component parent, final String id) { final IconPanel icon = new IconPanel( id, IconType.JIRA_SUPPORT, Model.of(parent.getString("tooltip.jiraSupport.field.title")), Model.of(parent.getString("tooltip.jiraSupport.field.content"))); if (isJIRAConfigured() == false) { icon.setVisible(false); } return icon; }
public VistaHorasForm(String id) { super(id); this.setDefaultModel(modeloHoras); this.setOutputMarkupId(true); this.fechaDesde = new DropDownChoice<String>( "fechaDesde", Model.of("7/2013"), VistaHorasPage.this.fechasModel); this.fechaDesde.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { VistaHorasPage.this.lstUsuariosModel.detach(); VistaHorasPage.this.lstUsuariosEnRojoModel.detach(); String seleccionado = fechaDesde.getModelObject(); List<String> fechas = Arrays.asList(seleccionado.split("/")); int dia = 1; int mes = Integer.parseInt(fechas.get(0)); int anio = Integer.parseInt(fechas.get(1)); VistaHorasPage.this.desde = new LocalDate(anio, mes, dia).toDate(); target.add(VistaHorasPage.this.listViewContainer); } }); this.fechaDesde.setOutputMarkupId(true); List<String> sectores = new ArrayList<String>(); sectores.add("TI"); sectores.add("E&P"); sectores.add("Administracion"); sectores.add("ExOdea"); sectores.add("Todos"); sectores.add("Ninguno"); sector = new DropDownChoice<String>("sector", Model.of("Todos"), sectores); sector.add( new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { VistaHorasPage.this.lstUsuariosModel.detach(); VistaHorasPage.this.lstUsuariosEnRojoModel.detach(); VistaHorasPage.this.sectorGlobal = sector.getModelObject(); target.add(VistaHorasPage.this.listViewContainer); } }); add(fechaDesde); add(sector); }
@Test public void testBasic3() { testButton( new WicketTester(), new FoundationTestAjaxLink("btn", Model.of("foo"), new ButtonOptions()), new ArrayList<String>()); }
/** * Constructor * * @param id the markup id * @param model the {@link IModel} * @param choices the list model of choices * @param renderer the renderer to be used, so the renderer item text and its values can be * dissociated */ public ComboBox( String id, IModel<String> model, List<? extends T> choices, ComboBoxRenderer<? super T> renderer) { this(id, model, Model.ofList(choices), renderer); }
/** * Constructor. * * @param id * @param inputComponent * @param labelModel optional * @param helpModel optional */ public InputBorder( final String id, final FormComponent<T> inputComponent, final IModel<String> labelModel, final IModel<String> helpModel) { super(id); Args.notNull(labelModel, "labelModel"); Args.notNull(helpModel, "helpModel"); // set html id so that this border can be refreshed by ajax this.setOutputMarkupId(true); // add the form component to the border this.inputComponent = inputComponent; add(this.inputComponent); // add the label WebMarkupContainer labelContainer = new WebMarkupContainer(labelContainerID); Label label = new Label(labelID, labelModel); label.setEscapeModelStrings(false); labelContainer.add(new AttributeModifier("for", Model.of(inputComponent.getMarkupId()))); labelContainer.add(label); addToBorder(labelContainer); // add the help label addToBorder(new Label(helpID, helpModel).setEscapeModelStrings(false)); // add the feedback panel with filter so that it only shows messages // relevant for this input component this.feedback = new FeedbackPanel(feedbackPanelID, new ContainerFeedbackMessageFilter(this)); addToBorder(this.feedback.setOutputMarkupId(true)); }
private CaptchaRatingPanel newRatingPanel() { IModel<Integer> calculatedRatingModel = new PropertyModel<Integer>(downloadModel, "calculatedRating"); IModel<Integer> numberOfVotesModel = new PropertyModel<Integer>(downloadModel, "numberOfVotes"); return new CaptchaRatingPanel( "vote", calculatedRatingModel, Model.of(5), numberOfVotesModel, hasVoted, true, getBubblePanel()) { private static final long serialVersionUID = 1L; @Override protected boolean onIsStarActive(int star) { Download download = downloadModel.getObject(); return star < ((int) (download.getCalculatedRating() + 0.5)); } @Override protected void onRatedAndCaptchaValidated(int rating, AjaxRequestTarget target) { Download download = downloadModel.getObject(); hasVoted.setObject(Boolean.TRUE); downloadService.rateDownload(rating, download); } @Override public boolean isEnabled() { return isAllowedToVote(); } }; }
private void addSaveResultsForm() { Form form = new SecureForm("saveResultsForm"); messageModel = Model.of(); form.add(new TooltipBehavior(messageModel)); add(form); form.add( new HelpBubble( "help", "The name of the search result to use.\n" + "By saving and assembling named search results, you can perform bulk artifact operations.")); form.add(newResultCombo("resultName")); Component saveResultsLink = createSaveResultsLink("saveResultsLink", "Save"); form.add(saveResultsLink); Component addResultsLink = createAddResultsLink("addResultsLink", "Add"); form.add(addResultsLink); form.add(createSubtractResultsLink("subtractResultsLink", "Subtract")); form.add(createIntersectResultsLink("intersectResultsLink", "Intersect")); form.add(new DefaultSubmit("defaultSubmit", saveResultsLink, addResultsLink)); addAdditionalFields(form); postInit(); }
public SearchBookForm(String id, String action) { super(id); this.action = action; setDefaultModel(new CompoundPropertyModel<SearchBookForm>(this)); TextField<String> title = new TextField<>("title"); title.setLabel(Model.of("Title")); add(title); TextField<String> author = new TextField<>("author"); author.setLabel(Model.of("Author")); author.setRequired(false); add(author); add(new Button("searchBookSubmit")); }
@Override protected TextField<String> newTextField( String id, IModel<String> valueModel, final ImportableRemoteRepo rowObject) { TextField<String> textField = super.newTextField(id, valueModel, rowObject); textField.setLabel(Model.of("Key")); textField.setOutputMarkupId(true); textField.setRequired(true); textField.add(new NameValidator("Invalid repository key '%s'.")); textField.add(new XsdNCNameValidator("Invalid repository key '%s'.")); textField.add( new AjaxFormComponentUpdatingBehavior("onkeyup") { @Override protected void onUpdate(AjaxRequestTarget target) { validateRepoKey(rowObject); // On each update, refresh import button to customize the warning messages of the call // decorator target.add(importButton); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { super.onError(target, e); AjaxUtils.refreshFeedback(); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new NoAjaxIndicatorDecorator(); } }); return textField; }
/** * Constructor. * * @param pageParameters the page parameters */ public EditTemplateFamilyPage(PageParameters pageParameters) { final TemplateFamily family = PapyrosDataUtil.loadTemplateFamily(pageParameters); oldKey = family.getKey(); BookmarkablePageLink<?> templateFamilyLink = new BookmarkablePageLink<>( "templateFamilyLink", TemplateFamilyPage.class, new PageParameters().add("key", family.getKey())); templateFamilyLink.add(new Label("templateFamilyName", family.getName())); add(templateFamilyLink); BeanStandardFormPanel<TemplateFamily> stdform = new BeanStandardFormPanel<TemplateFamily>("stdform", Model.of(family), true) { @Override protected void onSubmit() { String newKey = getBean().getKey(); String newName = getBean().getName(); QTemplateFamily qtf = QTemplateFamily.templateFamily; SQLUpdateClause update = EntityConnectionManager.getConnection().createUpdate(qtf); update.set(qtf.key, newKey).set(qtf.name, newName).where(qtf.key.eq(oldKey)); try { update.execute(); setResponsePage(TemplateFamilyPage.class, new PageParameters().add("key", newKey)); } catch (QueryException e) { keyComponent.error("could not change key"); } }; }; keyComponent = stdform.addTextField("Key", "key").setRequired().getFormComponent(); stdform.addTextField("Name", "name").setRequired(); stdform.addSubmitButton(); add(stdform); }
/** * Defines an {@link AddCommentPanel} object of a file or an album, either album or file must be * null, but not both. * * @param id This panel {@code wicket:id} * @param commentsPanel Comment panel, to reload it on adding comments, it can be {@code null} * @param album The {@link #album}, or {@code null} for a file panel * @param file The {@link #file}, or {@code null} for an album panel */ private AddCommentPanel(String id, ShowCommentsPanel commentsPanel, Album album, File file) { super(id); this.album = album; this.file = file; final ShowCommentsPanel showCommentsPanel = commentsPanel; final TextArea<String> text = new TextArea<String>("text", Model.of("")); text.setRequired(true); Form<Void> form = new Form<Void>("addCommentForm") { @Override protected void onSubmit() { String textString = cleanComment(text.getModelObject()); if (validateComment(textString)) { createComment(textString); if (showCommentsPanel != null) { showCommentsPanel.reload(); } } setResponsePage(this.getPage()); } }; add(form); form.add(text); form.add(new Label("maxLength", String.valueOf(Comment.MAX_TEXT_LENGTH))); }
/** Constructor. */ public CreateTemplateFamilyPage() { add(new BookmarkablePageLink<>("templateFamilyListLink", TemplateFamilyListPage.class)); BeanStandardFormPanel<TemplateFamily> stdform = new BeanStandardFormPanel<TemplateFamily>("stdform", Model.of(new TemplateFamily()), true) { @Override protected void onSubmit() { TemplateFamily templateFamily = getBean(); try { templateFamily.insert(); } catch (QueryException e) { System.out.println(e); } if (templateFamily.getId() == null) { keyComponent.error("could not create template family"); } else { setResponsePage( TemplateFamilyPage.class, new PageParameters().add("key", templateFamily.getKey())); } }; }; keyComponent = stdform.addTextField("Key", "key").setRequired().getFormComponent(); stdform.addTextField("Name", "name").setRequired(); stdform.addSubmitButton(); add(stdform); }
public class ImportServiceTable extends BaseDataTable<ServiceReference> { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") private static IColumn<ServiceReference, String>[] columns = new IColumn[] { new ServicePropertyColumn("Service Id", Constants.SERVICE_ID), new ObjectClassColumn(Model.of("Object classes")), new ServiceProviderColumn(Model.of("Provider")), }; public ImportServiceTable(String id, Bundle bundle) { super(id, Arrays.asList(columns), new ImportServiceDataProvider(bundle), Integer.MAX_VALUE); } }
public HomePage(PageParameters parameters) { super(parameters); recentWords = new HeaderPanel("panel", cid -> new ActivityHeaderPanel(cid)) .add(new Label("title", new ResourceModel("label.recently_added_words"))) .add( new ActivityPanel( "activity", Model.of(new WordDetailSearchCriteria()), new SupplierModel<>( () -> ZhGlossSession.get().getUserSettings().getTranscriptionSystem()), 20)); add(recentWords); add( new BootstrapBookmarkablePageLink<>("dictionaryLink", DictionaryPage.class, Type.Menu) .setIconType(Icons.ICON_DICTIONARY) .setLabel(new ResourceModel("label.dictionary")) .setSize(Size.Large)); add(new Label("dictionaryDescription", new ResourceModel("dictionaryDescription"))); add( new BootstrapBookmarkablePageLink<>("glossLink", GlossPage.class, Type.Menu) .setIconType(Icons.ICON_GLOSS) .setLabel(new ResourceModel("label.gloss")) .setSize(Size.Large)); add(new Label("glossDescription", new ResourceModel("glossDescription"))); }
public RepeatPage() { super(); add(new RepeatingPanel("repeater", Model.ofList(Arrays.asList("1", "2", "3")))); // add(new MoreRepeaterPanel<String>("repeater", new // ListDataProvider<String>(Arrays.asList("1", "2", "3")), 10)); }
@Override protected void onInitialize() { super.onInitialize(); TextField<String> userinput = new TextField<String>("userinput", Model.of("")); userinput.add( new AjaxFormSubmitBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) {} @Override protected void onError(AjaxRequestTarget target) {} @Override protected IAjaxCallDecorator getAjaxCallDecorator() { super.getAjaxCallDecorator(); return new MyAjaxCallDecorator(); } }); Form<Void> form = new Form<Void>("form"); add(form); form.add(userinput); AjaxRequestTarget.get(); getPageParameters(); }
@Override protected WebMarkupContainer newContent(String markupId) { Fragment fragment = new Fragment(markupId, "tooltip-fragment", markupProvider); fragment.add(new Label("content", Model.of(this.content))); return fragment; }