Java Code Examples for org.apache.wicket.model.PropertyModel

The following examples show how to use org.apache.wicket.model.PropertyModel. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@SuppressWarnings("serial")
private void addDurationColumns(final Item<GanttTreeTableNode> item, final GanttTreeTableNode node, final GanttTask ganttObject,
    final TaskDO task)
{
  final MinMaxNumberField<BigDecimal> durationField = new MinMaxNumberField<BigDecimal>("duration", new PropertyModel<BigDecimal>(
      ganttObject, "duration"), BigDecimal.ZERO, TaskEditForm.MAX_DURATION_DAYS);
  addColumn(item, durationField, null);
  new RejectSaveLinksFragment("rejectSaveDuration", item, durationField, task, task != null ? NumberFormatter.format(task.getDuration(),
      2) : "") {
    @Override
    protected void onSave()
    {
      task.setDuration(ganttObject.getDuration());
      taskDao.update(task);
    }

    @Override
    protected void onReject()
    {
      ganttObject.setDuration(task.getDuration());
    }
  };
}
 
Example 2
Source Project: oodt   Source File: TypeBrowser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param id
 *          The wicket:id component ID of this form.
 */
public AddCriteriaForm(String id) {
  super(id, new CompoundPropertyModel<ElementCrit>(new ElementCrit()));
  List<Element> ptypeElements = fm.safeGetElementsForProductType(type);
  Collections.sort(ptypeElements, new Comparator<Element>() {
    public int compare(Element e1, Element e2) {
      return e1.getElementName().compareTo(e2.getElementName());
    }
  });

  add(new DropDownChoice<Element>("criteria_list", new PropertyModel(
      getDefaultModelObject(), "elem"), new ListModel<Element>(
      ptypeElements), new ChoiceRenderer<Element>("elementName",
      "elementId")));
  add(new TextField<TermQueryCriteria>(
      "criteria_form_add_element_value",
      new PropertyModel<TermQueryCriteria>(getDefaultModelObject(), "value")));
  add(new Button("criteria_elem_add"));
}
 
Example 3
Source Project: syncope   Source File: PrivilegeWizardBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public Profile(final PrivilegeTO privilege) {
    setTitleModel(privilege.getKey() == null
            ? new StringResourceModel("privilege.new")
            : new StringResourceModel("privilege.edit", Model.of(privilege)));

    AjaxTextFieldPanel key = new AjaxTextFieldPanel(
            Constants.KEY_FIELD_NAME,
            Constants.KEY_FIELD_NAME, new PropertyModel<>(privilege, Constants.KEY_FIELD_NAME), false);
    key.setReadOnly(privilege.getKey() != null);
    key.setRequired(true);
    add(key);

    AjaxTextFieldPanel description = new AjaxTextFieldPanel(
            "description", "description", new PropertyModel<>(privilege, "description"), false);
    description.setRequired(false);
    add(description);
}
 
Example 4
Source Project: the-app   Source File: CartPanel.java    License: Apache License 2.0 6 votes vote down vote up
private Component cartView() {
    cartView = new ListView<CartItemInfo>("cart", cartListModel()) {
        @Override
        protected void populateItem(ListItem<CartItemInfo> item) {
            WebMarkupContainer cartItem = new WebMarkupContainer("item");
            cartItem.add(new Label("name", new PropertyModel<String>(item.getModel(), "product.name")));
            cartItem.add(new IndicatingAjaxLink<Void>("delete") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    IModel<CartItemInfo> model = item.getModel();
                    send(CartPanel.this, Broadcast.BREADTH, new RemoveFromCartEvent(model.getObject(), target));
                }
            });
            cartItem.add(new Label("price", new PriceModel(new PropertyModel<>(item.getModel(), "totalSum"))));
            item.add(cartItem);
        }
    };
    cartView.setReuseItems(false);
    cartView.setOutputMarkupId(true);
    return cartView;
}
 
Example 5
Source Project: Orienteer   Source File: OrienteerBasePage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initialize() {
	super.initialize();
	showChangedPerspectiveInfo();

	IModel<ODocument> perspectiveModel = PropertyModel.of(this, "perspective");
	IModel<List<ODocument>> perspectivesModel = new OQueryModel<>("select from " + PerspectivesModule.OPerspective.CLASS_NAME);
	add(createPerspectivesContainer("perspectivesContainer", perspectiveModel, perspectivesModel));
	add(new RecursiveMenuPanel("perspectiveItems", perspectiveModel));

	boolean signedIn = OrientDbWebSession.get().isSignedIn();
	add(new BookmarkablePageLink<>("login", LoginPage.class).setVisible(!signedIn));
	add(new BookmarkablePageLink<>("logout", LogoutPage.class).setVisible(signedIn));

	add(feedbacks = new OrienteerFeedbackPanel("feedbacks"));
	add(new ODocumentPageLink("myProfile", new PropertyModel<>(this, "session.user.document")));
	add(createUsernameLabel("username"));

	add(createSearchForm("searchForm", Model.of()));
}
 
Example 6
Source Project: sakai   Source File: FileSelectorPanel.java    License: Educational Community License v2.0 6 votes vote down vote up
public FileSelectorPanel(String id, String siteId, IModel model, boolean showDefaultBaseFoldersOnly) {
	super(id, model);
	this.siteId = siteId;
	this.showDefaultBaseFoldersOnly = showDefaultBaseFoldersOnly;
	
	// selected files
	HiddenField selectedFiles = new HiddenField("selectedFiles", new PropertyModel(this, "selectedFiles"));
	add(selectedFiles);
	
	// hover div (for disabling control)
	WebMarkupContainer containerHover = new WebMarkupContainer("containerHover");
	if(isEnabled()) {
		containerHover.add(new AttributeModifier("style", new Model("display: block")));
	}else{
		containerHover.add(new AttributeModifier("style", new Model("display: none")));
	}
	add(containerHover);
	
	add(ajaxResourcesLoader);
}
 
Example 7
Source Project: syncope   Source File: DomainWizardBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public KeymasterConfParams(final Domain domain) {
    JsonEditorPanel keymasterConfParams = new JsonEditorPanel(
            null, new PropertyModel<>(domain, "keymasterConfParams"), false, pageRef);
    keymasterConfParams.setOutputMarkupPlaceholderTag(true);
    keymasterConfParams.setVisible(false);
    add(keymasterConfParams);

    AjaxCheckBoxPanel defaultKeymasterConfParams = new AjaxCheckBoxPanel(
            "defaultKeymasterConfParams", "defaultKeymasterConfParams", Model.of(true), true);
    defaultKeymasterConfParams.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -6139318907146065915L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            keymasterConfParams.setVisible(
                    !BooleanUtils.toBoolean(defaultKeymasterConfParams.getField().getConvertedInput()));
            target.add(keymasterConfParams);
        }
    });
    add(defaultKeymasterConfParams);
}
 
Example 8
@SuppressWarnings("serial")
protected void addShowBackupScriptDialog()
{
  showBackupScriptDialog = new ModalDialog(parentPage.newModalDialogId()) {
    @Override
    public void init()
    {
      setTitle(getString("scripting.scriptBackup"));
      init(new Form<String>(getFormId()));
      {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("scripting.scriptBackup")).setLabelSide(false);
        final AceEditorPanel scriptBackup = new AceEditorPanel(fs.newChildId(), new PropertyModel<String>(data, "scriptBackupAsString"));
        fs.add(scriptBackup);
      }
    }
  };
  showBackupScriptDialog.setBigWindow().setOutputMarkupId(true);
  parentPage.add(showBackupScriptDialog);
  showBackupScriptDialog.init();

}
 
Example 9
@SuppressWarnings("serial")
private void addTitleColumns(final Item<GanttTreeTableNode> item, final GanttTreeTableNode node, final GanttTask ganttObject,
    final TaskDO task)
{
  final AjaxRequiredMaxLengthEditableLabel titleField = new AjaxRequiredMaxLengthEditableLabel("title", new PropertyModel<String>(
      ganttObject, "title"), HibernateUtils.getPropertyLength(TaskDO.class.getName(), "title"));
  titleField.setOutputMarkupId(true);
  // final RequiredMaxLengthTextField titleField = new RequiredMaxLengthTextField("title", new PropertyModel<String>(ganttObject,
  // "title"),
  // HibernateUtils.getPropertyLength(TaskDO.class.getName(), "title"));
  addColumn(item, titleField, null);
  new RejectSaveLinksFragment("rejectSaveTitle", item, titleField, task, task != null ? task.getTitle() : "") {
    @Override
    protected void onSave()
    {
      task.setTitle(ganttObject.getTitle());
      taskDao.update(task);
    }

    @Override
    protected void onReject()
    {
      ganttObject.setTitle(task.getTitle());
    }
  };
}
 
Example 10
Source Project: nextreports-server   Source File: AnalysisRuntimePanel.java    License: Apache License 2.0 6 votes vote down vote up
public AnalysisRuntimePanel(String id, ReportRuntimeModel model) {
	super(id);

	Label label = new Label("analysisLabel", getString("Analysis.run.name"));
	add(label);
	
	TextField<String> analysisText = new TextField<String>("analysisText", new PropertyModel(model, "analysisName"));    	
   	add(analysisText);
   	
   	AjaxLink analysisLink = new AjaxLink("analysisLink") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			// TODO Auto-generated method stub
			
		}
   		
   	}; 
   	add(analysisLink);
}
 
Example 11
Source Project: Orienteer   Source File: DefaultRegistrationPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    IModel<OrienteerUser> model = getModel();

    Form<?> form = new Form<>("form");

    form.add(new TextField<>("firstName", new PropertyModel<>(model, "firstName")).setRequired(true));
    form.add(new TextField<>("lastName", new PropertyModel<>(model, "lastName")).setRequired(true));
    form.add(createEmailField("email", new PropertyModel<>(model, "email")));

    TextField<String> passwordField = new PasswordTextField("password", passwordModel);
    TextField<String> confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));

    form.add(passwordField);
    form.add(confirmPasswordField);
    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));
    form.add(createRegisterButton("registerButton"));
    form.add(createSocialNetworksPanel("socialNetworks"));

    add(form);
    add(createFeedbackPanel("feedback"));
    setOutputMarkupPlaceholderTag(true);
}
 
Example 12
Source Project: webanno   Source File: ChainLayerTraitsEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeForm(Form<ChainLayerTraits> aForm)
{
    aForm.add(new ValidationModeSelect("validationMode", getLayerModel()));
    
    aForm.add(new AnchoringModeSelect("anchoringMode", getLayerModel()));
    
    aForm.add(new OverlapModeSelect("overlapMode", getLayerModel()));
    
    CheckBox linkedListBehavior = new CheckBox("linkedListBehavior");
    linkedListBehavior.setModel(PropertyModel.of(getLayerModel(), "linkedListBehavior"));
    aForm.add(linkedListBehavior);
    
    CheckBox crossSentence = new CheckBox("crossSentence");
    crossSentence.setOutputMarkupPlaceholderTag(true);
    crossSentence.setModel(PropertyModel.of(getLayerModel(), "crossSentence"));
    crossSentence.add(visibleWhen(() -> !isBlank(getLayerModelObject().getType())));
    aForm.add(crossSentence);
    
    TextArea<String> onClickJavascriptAction = new TextArea<String>("onClickJavascriptAction");
    onClickJavascriptAction.setModel(PropertyModel.of(getLayerModel(), "onClickJavascriptAction"));
    onClickJavascriptAction.add(new AttributeModifier("placeholder",
            "alert($PARAM.PID + ' ' + $PARAM.PNAME + ' ' + $PARAM.DOCID + ' ' + "
                    + "$PARAM.DOCNAME + ' ' + $PARAM.fieldname);"));
    aForm.add(onClickJavascriptAction);
}
 
Example 13
void init(final HRPlanningEntryDO entry)
{
  final boolean deleted = entry.isDeleted();
  final TextField<BigDecimal> unassignedHours = new TextField<BigDecimal>("unassignedHours", new PropertyModel<BigDecimal>(entry,
      "unassignedHours"));
  add(unassignedHours.setEnabled(!deleted));
  final TextField<BigDecimal> mondayHours = new TextField<BigDecimal>("mondayHours", new PropertyModel<BigDecimal>(entry, "mondayHours"));
  add(mondayHours.setEnabled(!deleted));
  final TextField<BigDecimal> tuesdayHours = new TextField<BigDecimal>("tuesdayHours", new PropertyModel<BigDecimal>(entry,
      "tuesdayHours"));
  add(tuesdayHours.setEnabled(!deleted));
  final TextField<BigDecimal> wednesdayHours = new TextField<BigDecimal>("wednesdayHours", new PropertyModel<BigDecimal>(entry,
      "wednesdayHours"));
  add(wednesdayHours.setEnabled(!deleted));
  final TextField<BigDecimal> thursdayHours = new TextField<BigDecimal>("thursdayHours", new PropertyModel<BigDecimal>(entry,
      "thursdayHours"));
  add(thursdayHours.setEnabled(!deleted));
  final TextField<BigDecimal> fridayHours = new TextField<BigDecimal>("fridayHours", new PropertyModel<BigDecimal>(entry, "fridayHours"));
  add(fridayHours.setEnabled(!deleted));
  final TextField<BigDecimal> weekendHours = new TextField<BigDecimal>("weekendHours", new PropertyModel<BigDecimal>(entry,
      "weekendHours"));
  add(weekendHours.setEnabled(!deleted));
}
 
Example 14
@SuppressWarnings("serial")
private void addCheckBox(final DivPanel checkBoxDivPanel, final ICalendarFilter filter, final String property, final String labelKey,
    final String tooltipKey, final boolean autoSubmit)
{
  final CheckBoxButton checkBoxButton = new CheckBoxButton(checkBoxDivPanel.newChildId(), new PropertyModel<Boolean>(filter, property),
      checkBoxDivPanel.getString(labelKey), autoSubmit);
  if (autoSubmit == false) {
    checkBoxButton.getCheckBox().add(new OnChangeAjaxBehavior() {
      @Override
      protected void onUpdate(final AjaxRequestTarget target)
      {
        // Do nothing (the model object is updated).
      }
    });
  }
  if (tooltipKey != null) {
    checkBoxButton.setTooltip(checkBoxDivPanel.getString(tooltipKey));
  }
  checkBoxDivPanel.add(checkBoxButton);
}
 
Example 15
Source Project: Orienteer   Source File: OrienteerBasePage.java    License: Apache License 2.0 6 votes vote down vote up
private WebMarkupContainer createPerspectivesContainer(String id, IModel<ODocument> perspectiveModel,
													   IModel<List<ODocument>> perspectivesModel) {
	return new WebMarkupContainer(id) {
		@Override
		protected void onInitialize() {
			super.onInitialize();
			add(createPerspectivesList("perspectives", perspectivesModel));
			Button perspectiveButton = new Button("perspectiveButton");

			perspectiveButton.add(new FAIcon("icon", new PropertyModel<>(perspectiveModel, "icon")));
			perspectiveButton.add(new Label("name", new ODocumentNameModel(perspectiveModel)));
			add(perspectiveButton);

			setOutputMarkupPlaceholderTag(true);
		}

		@Override
		protected void onConfigure() {
			super.onConfigure();
			List<ODocument> perspectives = perspectivesModel.getObject();
			setVisible(perspectives != null && perspectives.size() > 1);
		}
	};
}
 
Example 16
Source Project: syncope   Source File: ApplicationModalPanel.java    License: Apache License 2.0 6 votes vote down vote up
public ApplicationModalPanel(
        final ApplicationTO application,
        final boolean create,
        final BaseModal<ApplicationTO> modal,
        final PageReference pageRef) {

    super(modal, pageRef);
    this.application = application;
    this.create = create;

    modal.setFormModel(application);

    AjaxTextFieldPanel key = new AjaxTextFieldPanel(
            Constants.KEY_FIELD_NAME,
            Constants.KEY_FIELD_NAME,
            new PropertyModel<>(application, Constants.KEY_FIELD_NAME), false);
    key.setReadOnly(!create);
    key.setRequired(true);
    add(key);

    AjaxTextFieldPanel description = new AjaxTextFieldPanel(
            "description", "description", new PropertyModel<>(application, "description"), false);
    description.setRequired(false);
    add(description);
}
 
Example 17
Source Project: inception   Source File: QualifierFeatureEditor.java    License: Apache License 2.0 5 votes vote down vote up
private AutoCompleteTextField<KBProperty> createSelectPropertyAutoCompleteTextField()
{
    AutoCompleteTextField<KBProperty> field = new AutoCompleteTextField<KBProperty>("newRole",
        new PropertyModel<KBProperty>(this, "selectedRole"),
        new TextRenderer<KBProperty>("uiLabel"), KBProperty.class)
    {

        private static final long serialVersionUID = 1458626823154651501L;

        @Override protected List<KBProperty> getChoices(String input)
        {
            ConceptFeatureTraits traits = factService.getFeatureTraits(project);
            String repoId = traits.getRepositoryId();
            if (!(repoId == null || kbService.isKnowledgeBaseEnabled(project, repoId))) {
                return Collections.emptyList();
            }
            return factService.listProperties(project, traits);
        }

        @Override
        public void onConfigure(JQueryBehavior behavior)
        {
            super.onConfigure(behavior);

            behavior.setOption("autoWidth", true);
        }

        @Override protected IJQueryTemplate newTemplate()
        {
            return KendoChoiceDescriptionScriptReference.template();
        }
    };

    return field;
}
 
Example 18
Source Project: nextreports-server   Source File: MailPanel.java    License: Apache License 2.0 5 votes vote down vote up
protected void initSpecificComponents() {
	add(new Label("changedFileName", getString("ActionContributor.Run.destination.changedFileName")));
	TextField<String> fileNameField = new TextField<String>("changedFileNameField", new PropertyModel<String>(destination,
			"changedFileName"));
	fileNameField.setLabel(new Model<String>(getString("ActionContributor.Run.destination.changedFileName")));
	fileNameField.setRequired(false);
	fileNameField.add(new JcrNameValidator());
	add(fileNameField);
}
 
Example 19
private void addComponents() {
    add(new Label("name", getString("name")));
    
    TextField<String> displayNameField = new TextField<String>("nameField", new PropertyModel<String>(destination, "name"));
    displayNameField.setLabel(new Model<String>( getString("name")));
    displayNameField.setRequired(true);
    displayNameField.add(new JcrNameValidator());
    add(displayNameField);

    initComponents();
}
 
Example 20
@SuppressWarnings("serial")
@Override
protected void init()
{
  super.init();
  timesheetPageSupport = new TimesheetPageSupport(parentPage, gridBuilder, timesheetDao, data);
  gridBuilder.newGridPanel();
  {
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("task"));
    fs.addCheckBox(new PropertyModel<Boolean>(this, "updateTask"), getString("update") + ":", getString("massupdate.updateTask"));
    final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(data, "task"), parentPage, "taskId");
    fs.add(taskSelectPanel);
    taskSelectPanel.init();
  }
  {
    kost2Fieldset = new FieldsetPanel(gridBuilder.getPanel(), getString("fibu.kost2")) {
      @Override
      public boolean isVisible()
      {
        return CollectionUtils.isNotEmpty(kost2List);
      }
    };
    kost2List = timesheetDao.getKost2List(data);
    final LabelValueChoiceRenderer<Integer> kost2ChoiceRenderer = getKost2LabelValueChoiceRenderer();
    kost2Choice = TimesheetEditForm.createCost2ChoiceRenderer(kost2Fieldset.getDropDownChoiceId(), timesheetDao, taskTree,
        kost2ChoiceRenderer, data, kost2List);
    kost2Fieldset.add(kost2Choice);
  }
  {
    timesheetPageSupport.addLocation();
  }
}
 
Example 21
Source Project: nextreports-server   Source File: JasperRuntimePanel.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void addComponents() {

    // initialize model
    for (QueryParameter parameter : convertList) {
        if (!runtimeModel.isEdit() || (USER_PARAM.equals(parameter.getName()))) {
            JasperRuntimeParameterModel jasperRuntimeModel = createRuntimeModel(parameter);
            runtimeModel.getParameters().put(parameter.getName(), jasperRuntimeModel);
        }
    }
    if (!runtimeModel.isEdit()) {
        // if some parameters initialized have default values, their dependent parameters
        // have to be initialized too
        for (QueryParameter qp : depParameters) {
            populateDependentParameters(qp, null);
        }
    }

    ListView<QueryParameter> listView = new ListView<QueryParameter>("params", new ArrayList<QueryParameter>(convertMap.values())) {

        @Override
        protected void populateItem(ListItem<QueryParameter> item) {
            createItem(item);
        }

    };
    listView.setReuseItems(true);
    add(listView);

    add(new DropDownChoice("exportType", new PropertyModel(runtimeModel, "exportType"), typeList).setRequired(true));                
}
 
Example 22
Source Project: nextreports-server   Source File: NextRuntimePanel.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
  public void addWicketComponents() {    	        	    	
  	
      final DropDownChoice<String> exportChoice = new DropDownChoice<String>("exportType", new PropertyModel<String>(runtimeModel, "exportType"), typeList,
      		new ChoiceRenderer<String>() {
			@Override
			public Object getDisplayValue(String name) {
				if (name.equals(ReportConstants.ETL_FORMAT)) {
					return getString("Analysis.source");
				} else {
					return name;
				}
			}
});
      exportChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
          @Override
          protected void onUpdate(AjaxRequestTarget target) {
              String format = (String) getFormComponent().getConvertedInput();
              if (ReportConstants.ETL_FORMAT.equals(format)) {
			System.out.println("***** ETL selected");
			//analysisPanel.setVisible(true);
		} else {
			System.out.println("***** " + format);
			//analysisPanel.setVisible(false);
		}
              //target.add(analysisPanel);
          }
      });
	
      exportChoice.setRequired(true);
      add(exportChoice);
      
      if (report.isAlarmType() || report.isIndicatorType() || report.isDisplayType()) {
      	exportChoice.setEnabled(false);
      } else {
      	exportChoice.setRequired(true);
      }
      
      
  }
 
Example 23
public DashboardStatisticsPanel(String id) {			
super(id, new StatisticsModel());
	
add(new Label("dashboardNo", new PropertyModel(getModel(), "dashboardNo")));
add(new Label("linkNo", new PropertyModel(getModel(), "linkNo")));
add(new Label("widgetNo", new PropertyModel(getModel(), "widgetNo")));
add(new Label("tableNo", new PropertyModel(getModel(), "tableNo")));
add(new Label("chartNo", new PropertyModel(getModel(), "chartNo")));
add(new Label("alarmNo", new PropertyModel(getModel(), "alarmNo")));
add(new Label("indicatorNo", new PropertyModel(getModel(), "indicatorNo")));
add(new Label("displayNo", new PropertyModel(getModel(), "displayNo")));
add(new Label("drillDownNo", new PropertyModel(getModel(), "drillDownNo")));
add(new Label("pivotNo", new PropertyModel(getModel(), "pivotNo")));
}
 
Example 24
Source Project: yes-cart   Source File: CountryModel.java    License: Apache License 2.0 5 votes vote down vote up
public CountryModel(final PropertyModel propertyModel, final List<Country> countryList) {
    this.propertyModel = propertyModel;
    final String singleSelectedKey = (String) propertyModel.getObject();
    if (StringUtils.isNotBlank(singleSelectedKey)) {
        for (Country c : countryList) {
            if (singleSelectedKey.equals(c.getCountryCode())) {
                country = c;
                break;
            }
        }
    }

}
 
Example 25
@Test
public void maxLength()
{
  PropertyModel<String> model = new PropertyModel<String>(new PFUserDO(), "username");
  assertInteger(255, MaxLengthTextField.getMaxLength(model));
  assertInteger(255, MaxLengthTextField.getMaxLength(model, 300));
  assertInteger(100, MaxLengthTextField.getMaxLength(model, 100));

  model = new PropertyModel<String>(new BaseSearchFilter(), "searchString");
  Assert.assertNull(MaxLengthTextField.getMaxLength(model));
  assertInteger(100, MaxLengthTextField.getMaxLength(model, 100));

  Assert.assertNull(MaxLengthTextField.getMaxLength(Model.of("test")));
  assertInteger(100, MaxLengthTextField.getMaxLength(Model.of("test"), 100));
}
 
Example 26
Source Project: Orienteer   Source File: BirtManagementPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void populateItem(ListItem<BirtReportParameterDefinition> item) {
	String name = item.getModelObject().getName();
	item.add(new Label("parameterName",name));
	String defaultValue = item.getModelObject().getDefaultValue();
	Object value = reportPanel.getParameter(name);
	if (Strings.isNullOrEmpty((String) value)){
		reportPanel.setParameter(name, defaultValue);
	}
	item.add(new TextField<>("parameterInput",new PropertyModel<>(reportPanel,"config.parameters["+name+"]"))
			.add(new AjaxFormComponentUpdatingBehavior("change"){

				/**
				 * 
				 */
				private static final long serialVersionUID = 1L;

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					try {
						reportPanel.setCurrentPage(0);
						reportPanel.updateReportCache();
				        target.add(reportPanel);
				        target.add(pager);
					} catch (EngineException e) {
						String message = e.getMessage();
						error("Cannot update report cache:"+message);
						LOG.error("Can't update report cache", e);
					}
				}
				
	}));
}
 
Example 27
Source Project: syncope   Source File: AbstractAuxClasses.java    License: Apache License 2.0 5 votes vote down vote up
public <T extends AnyTO> AbstractAuxClasses(final AnyWrapper<T> modelObject, final List<String> anyTypeClasses) {
    super();
    setOutputMarkupId(true);

    List<AnyTypeClassTO> allAnyTypeClasses = listAnyTypecClasses();

    List<String> choices = new ArrayList<>();
    for (AnyTypeClassTO aux : allAnyTypeClasses) {
        if (!anyTypeClasses.contains(aux.getKey())) {
            choices.add(aux.getKey());
        }
    }
    Collections.sort(choices);
    add(new AjaxPalettePanel.Builder<String>().setAllowOrder(true).build("auxClasses",
            new PropertyModel<>(modelObject.getInnerObject(), "auxClasses"),
            new ListModel<>(choices)).hideLabel().setOutputMarkupId(true));

    // ------------------
    // insert changed label if needed
    // ------------------
    if (modelObject instanceof UserWrapper
            && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(
                    modelObject.getInnerObject().getAuxClasses(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getAuxClasses())) {
        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }
    // ------------------
}
 
Example 28
private TextField<String> getNewEMailField(final String wicketId)
{
  existingMailAddresses = new ArrayList<String>();
  if (model.getPollAttendeeList() != null) {
    for (final PollAttendeeDO attendee : model.getPollAttendeeList()) {
      if (attendee.getEmail() != null) {
        emailList += attendee.getEmail() + "; ";
        existingMailAddresses.add(attendee.getEmail());
      }
    }
  }
  final PropertyModel<String> mailModel = new PropertyModel<String>(this, "emailList");
  final TextField<String> eMailField = new TextField<String>(wicketId, mailModel);
  return eMailField;
}
 
Example 29
Source Project: syncope   Source File: NotificationWizardBuilder.java    License: Apache License 2.0 5 votes vote down vote up
public Details(final NotificationWrapper modelObject) {
    NotificationTO notificationTO = modelObject.getInnerObject();
    boolean createFlag = notificationTO.getKey() == null;

    AjaxTextFieldPanel sender = new AjaxTextFieldPanel("sender", getString("sender"),
            new PropertyModel<>(notificationTO, "sender"));
    sender.addRequiredLabel();
    sender.addValidator(EmailAddressValidator.getInstance());
    add(sender);

    AjaxTextFieldPanel subject = new AjaxTextFieldPanel("subject", getString("subject"),
            new PropertyModel<>(notificationTO, "subject"));
    subject.addRequiredLabel();
    add(subject);

    AjaxDropDownChoicePanel<String> template = new AjaxDropDownChoicePanel<>(
            "template", getString("template"),
            new PropertyModel<>(notificationTO, "template"));
    template.setChoices(restClient.listTemplates().stream().
            map(EntityTO::getKey).collect(Collectors.toList()));

    template.addRequiredLabel();
    add(template);

    AjaxDropDownChoicePanel<TraceLevel> traceLevel = new AjaxDropDownChoicePanel<>(
            "traceLevel", getString("traceLevel"),
            new PropertyModel<>(notificationTO, "traceLevel"));
    traceLevel.setChoices(List.of(TraceLevel.values()));
    traceLevel.addRequiredLabel();
    add(traceLevel);

    final AjaxCheckBoxPanel isActive = new AjaxCheckBoxPanel("isActive",
            getString("isActive"), new PropertyModel<>(notificationTO, "active"));
    if (createFlag) {
        isActive.getField().setDefaultModelObject(Boolean.TRUE);
    }
    add(isActive);
}
 
Example 30
public FavoritesChoicePanel(final String componentId, final UserPrefArea userPrefArea, final Integer tabIndex, final String cssClass)
{
  super(componentId);
  this.userPrefArea = userPrefArea;
  this.tabIndex = tabIndex;
  this.cssClass = cssClass;
  setModel(new PropertyModel<String>(this, "dummy"));
}