List of usage examples for org.apache.wicket.model Model Model
public Model()
From source file:almira.sample.web.AbstractBasePage.java
License:Apache License
/** * Constructor.// w w w.j a v a2 s . c o m */ AbstractBasePage() { super(); // http://apache-wicket.1842946.n4.nabble.com/wicket-message-in-the-title-td1843627.html add(new Label("pageTitle", new ResourceModel("catapult.title"))); add(new BookmarkablePageLink<Void>("homeLink", IndexPage.class)); add(new BookmarkablePageLink<Void>("adminLink", AdminPage.class)); add(new LocaleDropDownPanel("localeSelectPanel", Arrays.asList(new Locale("es"), new Locale("de"), new Locale("en"), new Locale("fr"), new Locale("it")))); add(new Label("version", ((MainApplication) getApplication()).getVersion())); add(new Label("session", new PropertyModel<String>(this, "session.id"))); add(new SearchPanel("searchPanel")); add(new Label("footertext", footerTextService.getText())); // Page 87, Wicket in Action add(new Label("clock", new Model<String>() { @Override public String getObject() { final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy | HH:mm:ss.mmm", getSession().getLocale()); return dateFormat.format(new Date()); } })); }
From source file:ar.edu.udc.cirtock.view.intranet.html.InsumoPage.java
License:Apache License
@SuppressWarnings("unchecked") public InsumoPage() { cerrar = new Link<IndexPage>("cerrar") { /**/*from w ww . j av a 2 s. c o m*/ * */ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(IndexPage.class); } }; producto = new Link<ProductoPage>("producto") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(ProductoPage.class); } }; herramienta = new Link<HerramientaPage>("herramienta") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(HerramientaPage.class); } }; formBusqueda = new Form("form_busqueda"); busquedaInput = new TextField<String>("busquedaInput", new Model<String>()); formBusqueda.add(busquedaInput); formBusqueda.add(new Button("busquedaBoton") { @Override public void onSubmit() { String busqueda = busquedaInput.getModelObject(); Connection conn; try { conn = CirtockConnection.getConection("cirtock", "cirtock", "cirtock"); insumos = Consultas.obtenerInsumos(conn, null, busqueda, null); lista.setList(insumos); } catch (CirtockException e) { System.out.println(e.getMessage()); } } }); add(formBusqueda); add(cerrar); add(producto); add(herramienta); add(lista); add(new Link<FormularioInsumo>("nuevo") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(FormularioInsumo.class); } }); }
From source file:ar.edu.udc.cirtock.view.intranet.negocio.FormularioInsumo.java
License:Apache License
public FormularioInsumo(final PageParameters parameters) { super(parameters); add(new FeedbackPanel("feedbackErrors", new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR))); formulario = new Form("formulario_insumo"); nombre = new RequiredTextField<String>("nombre", new Model()); nombre.add(new IValidator<String>() { @Override//from ww w . j a va 2s . c om public void validate(IValidatable<String> validatable) { String nombre = validatable.getValue().trim().toUpperCase(); if (!nombre.matches("^[\\w\\s]{3,20}$")) { ValidationError error = new ValidationError(); error.setMessage("El campo 'nombre' no es valido"); validatable.error(error); } } }); formulario.add(nombre); descripcion = new RequiredTextField<String>("descripcion", new Model()); descripcion.add(new IValidator<String>() { @Override public void validate(IValidatable<String> validatable) { String descripcion = validatable.getValue().trim().toUpperCase(); if (!descripcion.matches("^[A-Za-z ]{3,50}$")) { ValidationError error = new ValidationError(); error.setMessage("El campo 'descripcion' no es valido"); validatable.error(error); } } }); formulario.add(descripcion); cantidad = new NumberTextField<Integer>("cantidad", new Model()); cantidad.setType(Integer.class); cantidad.add(new IValidator<Integer>() { @Override public void validate(IValidatable<Integer> validatable) { Integer cantidad = validatable.getValue(); if (cantidad < 0) { ValidationError error = new ValidationError(); error.setMessage("El campo 'cantidad' no es valido"); validatable.error(error); } } }); formulario.add(cantidad); formulario.add(new Button("enviar") { /** * */ private static final long serialVersionUID = 1L; public void onSubmit() { String desc = (String) descripcion.getModelObject(); String nomb = (String) nombre.getModelObject(); Integer cant = cantidad.getModelObject(); Connection conn = null; try { conn = CirtockConnection.getConection("cirtock", "cirtock", "cirtock"); Insumo ins = new Insumo(); ins.setDescripcion(desc); ins.setNombre(nomb); ins.setCantidad(cant); ins.insert("", conn); } catch (CirtockException e) { System.out.println("Error al acceder a la base de datos"); } finally { try { conn.close(); } catch (SQLException e) { ; } } setResponsePage(InsumoPage.class); }; }); add(formulario); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.stopwatch.AssignedTaskTimerPanel.java
License:Apache License
/** * Displays the Panel with all wicket elements. *//*from w w w. j a va 2 s . c om*/ private void displayPanel() { taskTimerForm = new Form<Object>("timerTaskForm"); add(taskTimerForm); taskTimerForm.add(new Label("taskId", task.getId().toString())); taskTimerForm.add(new Label("taskDescription", task.getDescription())); startstop = new AjaxButton("startStopTimer", new Model<String>(), taskTimerForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { if (!started) { owner.startTimerForIssue(task); started = true; this.getModel().setObject("Stop"); } else { owner.stopTimerForIssue(task, target); started = false; this.getModel().setObject("Start"); } this.setLabel(this.getModel()); target.addComponent(this); } }; taskTimerForm.add(startstop); taskTimerForm.add(new AjaxButton("closeTask", taskTimerForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { started = false; // beh.stop(); owner.stopTimerForIssue(task, target); owner.closeTask(task, target); } }); lab = new Label("totalEffort", TiTATimeConverter.getDuration2String(effort != null ? effort : 0L)); taskTimerForm.add(lab); beh = new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)); lab.add(beh); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.TaskListPanel.java
License:Apache License
/** * Shows the header and configuration for the tasklist. *//* ww w. j a v a 2 s.co m*/ private void displayHeader() { dropDownView = new DropDownChoice<String>("dropdownGrouping", new Model<String>(), groupingList) { @Override protected boolean wantOnSelectionChangedNotifications() { return true; } /** * Called when a option is selected of a dropdown list that wants to be * notified of this event. * * @param newSelection The newly selected object of the backing model */ @Override protected void onSelectionChanged(final String newSelection) { } }; dropDownView.setOutputMarkupId(true); dropDownView.setDefaultModelObject(groupingList.get(0)); dropDownView.setNullValid(false); dropDownView.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { changeGrouping(project); target.addComponent(containerTaskList); } }); tasklistForm.add(dropDownView); tasklistForm.add(new Label("dummy", "")); tasklistForm.add(new AjaxButton("updateTaskList") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { loadIssueTrackerTasks(project); target.addComponent(containerTaskList); } }); // general timer panel generalTimer = new GeneralTimerPanel("generalTimer", this); tasklistForm.add(generalTimer); }
From source file:au.org.emii.geoserver.extensions.filters.LayerFilterConfigurationPage.java
License:Open Source License
private IModel<FilterConfiguration> getFilterConfigurationModel() throws NamingException, ParserConfigurationException, SAXException, IOException { // we want configured filters on the left final FilterConfiguration config = new FilterConfiguration(getDataDirectory(), FilterMerge.merge(getLayerProperties(), getConfiguredFilters())); return new Model<FilterConfiguration>() { @Override//ww w . java 2 s . co m public FilterConfiguration getObject() { return config; } }; }
From source file:au.org.emii.geoserver.extensions.filters.LayerFilterForm.java
License:Open Source License
public LayerFilterForm(final String id, IModel<FilterConfiguration> model) { super(id, model); add(new ListView<Filter>("layerDataProperties", model.getObject().getFilters()) { public void populateItem(final ListItem<Filter> item) { final Filter filter = item.getModelObject(); item.add(new CheckBox("propertyEnabled", new PropertyModel<Boolean>(filter, "enabled"))); item.add(new Label("propertyName", filter.getName())); item.add(new TextField<String>("propertyType", new Model<String>() { @Override/*w w w . ja v a 2s. c o m*/ public String getObject() { return filter.getType(); } @Override public void setObject(final String value) { filter.setType(value); } })); item.add(new TextField<String>("propertyLabel", new Model<String>() { @Override public String getObject() { return filter.getLabel(); } @Override public void setObject(final String value) { filter.setLabel(value); } })); item.add(new CheckBox("propertyWmsFilter", new Model<Boolean>() { @Override public Boolean getObject() { return new Boolean(!filter.getVisualised().booleanValue()); } @Override public void setObject(Boolean value) { filter.setVisualised(new Boolean(!value.booleanValue())); } })); item.add(new CheckBox("propertyWfsExcluded", new PropertyModel<Boolean>(filter, "excludedFromDownload"))); } }); add(saveLink()); add(cancelLink()); }
From source file:au.org.theark.arkcalendar.component.dataentry.CheckGroupDataEntryPanel.java
License:Open Source License
/** * NumberDataEntryPanel Constructor/*from w w w . ja va 2s . c o m*/ * @param id - component id * @param dataModel - must be a model for a String dataValue * @param labelModel - field-specific String label model to be used for feedback * @param allChoicesList - list of choices for the Dropdown */ public CheckGroupDataEntryPanel(String id, IModel<String> dataModel, IModel<String> labelModel, final ArrayList<EncodedValueVO> allChoicesList, ChoiceRenderer<EncodedValueVO> renderer) { super(id, labelModel); missingValueVo = null; underlyingDataModel = dataModel; // dataValueModel = new Model<ArrayList<EncodedValueVO>>(selectedList); dataValueModel = new Model<ArrayList<EncodedValueVO>>() { private static final long serialVersionUID = 1L; public ArrayList<EncodedValueVO> getObject() { String textDataValue = underlyingDataModel.getObject(); ArrayList selectedEvvos = new ArrayList<EncodedValueVO>(); if (textDataValue != null && !textDataValue.isEmpty()) { List<String> encodeKeyValueList = Arrays.asList(textDataValue.split(";")); for (String keyValue : encodeKeyValueList) { // if(key is in the list of our keys in allPossibilities)) then add it to out list to return for (EncodedValueVO evvo : allChoicesList) { if (keyValue.equalsIgnoreCase(evvo.getKey())) { selectedEvvos.add(evvo); } } } } return selectedEvvos; } public void setObject(ArrayList<EncodedValueVO> object) { String keyConcat = ""; if (object == null || object.isEmpty()) { underlyingDataModel.setObject(null); } else { for (EncodedValueVO evvo : object) { keyConcat += evvo.getKey() + ";"; } underlyingDataModel.setObject(keyConcat); } } }; checkBoxMultipleChoice = new CheckBoxMultipleChoice("checkGroupDataValue", dataValueModel, allChoicesList, renderer); //checkBoxMultipleChoice.setNullValid(true); // nullValid allows you to set the "Choose One" option checkBoxMultipleChoice.setLabel(fieldLabelModel); // set the ${label} for feedback messages this.add(checkBoxMultipleChoice); }
From source file:au.org.theark.core.web.component.worksheet.ArkExcelWorkSheetAsGrid.java
License:Open Source License
@SuppressWarnings({ "unchecked" })
private Loop createHeadings() {
return new Loop("heading", new PropertyModel(sheetMetaData, "cols")) {
private static final long serialVersionUID = -7027878243061138904L;
public void populateItem(LoopItem item) {
final int col = item.getIndex();
/*/*from www . jav a2 s . co m*/
* this model used for Label component gets data from cell instance Because we are interacting directly with the sheet instance which gets
* updated each time we upload a new Excel File, the value for each cell is automatically updated
*/
IModel<Object> model = new Model() {
private static final long serialVersionUID = 1144128566137457199L;
@Override
public Serializable getObject() {
Cell cell = sheet.getCell(col, 0);
return cell.getContents();
}
};
Label cellData = new Label("cellHead", model);
item.add(cellData);
}
};
}
From source file:au.org.theark.lims.web.component.inventory.panel.box.display.GridBoxPanel.java
License:Open Source License
/** * Creates the header of the table for the represented InvBox in question * @param invBox// w w w.j a v a 2 s .c o m * @return */ @SuppressWarnings({ "unchecked" }) private Loop createHeadings(final InvBox invBox) { String colRowNoType = ""; if (invBox.getId() != null) { colRowNoType = invBox.getColnotype().getName(); } else { // handle for null invBox (eg when backend list of cells corrupted) return new Loop("heading", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { Label colLabel = new Label("cellHead", ""); item.add(colLabel.setVisible(false)); } @Override public boolean isVisible() { return false; } }; } final String colNoType = colRowNoType; // Outer Loop instance, using a PropertyModel to bind the Loop iteration to invBox "noofcol" value return new Loop("heading", new PropertyModel(invBox, "noofcol")) { private static final long serialVersionUID = -7027878243061138904L; public void populateItem(LoopItem item) { final int col = item.getIndex(); IModel<String> colModel = new Model() { private static final long serialVersionUID = 1144128566137457199L; @Override public Serializable getObject() { String label = new String(); if (colNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (col + 65); label = new Character(character).toString(); } else { label = new Integer(col + 1).toString(); } return label; } }; // Create the col number/label Label colLabel = new Label("cellHead", colModel); item.add(colLabel); } }; }