List of usage examples for org.apache.wicket.ajax.attributes AjaxAttributeName MARKUP_ID
AjaxAttributeName MARKUP_ID
To view the source code for org.apache.wicket.ajax.attributes AjaxAttributeName MARKUP_ID.
Click Source Link
From source file:org.efaps.ui.wicket.components.values.SnippletField.java
License:Apache License
/** * Instantiates a new snipplet field.//from w w w . j a v a 2 s. com * * @param _wicketId wicket if of this component * @param _model model for this component * @param _labelModel label for this component * @param _uiField the ui field */ public SnippletField(final String _wicketId, final IModel<String> _model, final AbstractUIField _uiField) { super(_wicketId, _model); setEscapeModelStrings(false); this.fieldConfig = _uiField == null ? null : _uiField.getFieldConfiguration(); if (_uiField != null && _uiField.isFieldUpdate()) { final List<EventDefinition> events = _uiField.getFieldConfiguration().getField() .getEvents(EventType.UI_FIELD_UPDATE); String eventName = "change"; for (final EventDefinition event : events) { eventName = event.getProperty("Event") == null ? "change" : event.getProperty("Event"); } final String html = (String) getDefaultModelObject(); final String tmpId; if (html.contains(IUserInterface.EFAPSTMPTAG)) { tmpId = RandomStringUtils.randomAlphanumeric(12); setDefaultModelObject(html.replace(IUserInterface.EFAPSTMPTAG, " id=\"" + tmpId + "\" ")); } else { tmpId = null; } add(new AjaxFieldUpdateBehavior(eventName, Model.of(_uiField), false) { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void postprocessConfiguration(final JSONObject _attributesJson, final Component _component) throws JSONException { if (tmpId != null) { _attributesJson.put(AjaxAttributeName.MARKUP_ID.jsonName(), tmpId); } } }); } }