org.apache.wicket.markup.html.WebComponent Java Examples

The following examples show how to use org.apache.wicket.markup.html.WebComponent. 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 check out the related API usage on the sidebar.
Example #1
Source File: HtmlAnnotationEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
private static void initAnnotatorJs(IHeaderResponse aResponse, WebComponent aContainer,
        StoreAdapter aAdapter)
{
    String callbackUrl = aAdapter.getCallbackUrl().toString();
    StringBuilder script = new StringBuilder();
    script.append(
            "var ann = $('#" + aContainer.getMarkupId() + "').annotator({readOnly: true});");
    script.append("ann.annotator('addPlugin', 'Store', {");
    script.append("    prefix: null,");
    script.append("    emulateJSON: true,");
    script.append("    emulateHTTP: true,");
    script.append("    urls: {");
    script.append("        read:    '" + callbackUrl + "',");
    script.append("        create:  '" + callbackUrl + "',");
    script.append("        update:  '" + callbackUrl + "',");
    script.append("        destroy: '" + callbackUrl + "',");
    script.append("        search:  '" + callbackUrl + "'");
    script.append("    }");
    script.append("});");
    // script.append("Wicket.$('" + vis.getMarkupId() + "').annotator = ann;");
    aResponse.render(OnDomReadyHeaderItem.forScript(script.toString()));
}
 
Example #2
Source File: UploadIFrame.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public UploadIFrame(FieldValueModel fieldValueModel) {
  this.fieldValueModel = fieldValueModel;

  // add header contributor for stylesheet
  add(CSSPackageResource.getHeaderContribution(getStylesheet()));
  
  WebMarkupContainer container = new WebMarkupContainer("container");
  container.setOutputMarkupId(true);
  add(container);
  // add form
  container.add(new UploadForm("form", container));
  // add onUploaded method
  container.add(new WebComponent("onUploaded") {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      if (uploaded) {
        replaceComponentTagBody(markupStream, openTag,
            "window.parent." + getOnUploadedCallback() + "('', '')");
        uploaded = false;
      }
    }            
  });
}
 
Example #3
Source File: UploadPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public UploadPanel(String id, FieldInstanceImageField parentField) {
  super(id);
  this.parentField = parentField;

  // add onUploaded behavior
  final OnUploadedBehavior onUploadBehavior = new OnUploadedBehavior();
  add(onUploadBehavior);
  add(new WebComponent("onUploaded") {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      // calling it through setTimeout we ensure that the callback is called
      // in the proper execution context, that is the parent frame
      replaceComponentTagBody(markupStream, openTag,
          "function onUpload_" + UploadPanel.this.getMarkupId() +
          "(uploadedFile, clientFileName) {  window.setTimeout(function() { " + // window.location.reload(true); " +
          onUploadBehavior.getCallback() + "; }, 0 )}");
      } 
  });        
}
 
Example #4
Source File: AvatarUploadField.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(dataField = new TextField<String>("data", Model.of(getModelObject())));
	
	WebComponent fileInput = new WebComponent("fileInput");
	fileInput.setOutputMarkupId(true);
	add(fileInput);
	
	add(new WebMarkupContainer("fileLabel") {

		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			tag.put("for", fileInput.getMarkupId());
		}
		
	});
	
	add(behavior = new AbstractPostAjaxBehavior() {
		
		@Override
		protected void respond(AjaxRequestTarget target) {
			send(AvatarUploadField.this, Broadcast.BUBBLE, new AvatarFileSelected(target));	
		}
		
	});
}
 
Example #5
Source File: ImagePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param image
 * @return this for chaining.
 */
public ImagePanel replaceImage(final WebComponent image)
{
  removeImage();
  add(this.image = image);
  return this;
}
 
Example #6
Source File: FieldInstanceHTMLArea.java    From ontopia with Apache License 2.0 4 votes vote down vote up
public FieldInstanceHTMLArea(String id, FieldValueModel _fieldValueModel) {
  super(id);
  this.fieldValueModel = _fieldValueModel;
  
  OccurrenceIF occ = (OccurrenceIF)fieldValueModel.getObject();
  this.oldValue = (occ == null ? null : occ.getValue());
  setDefaultModel(new Model<String>(oldValue));
  
  this.textArea = new TextArea<String>("field", new Model<String>(oldValue)) {      
    @Override
    protected void onComponentTag(ComponentTag tag) {
      tag.setName("textarea");
      tag.put("cols", cols);
      tag.put("rows", rows);
      tag.put("class", getMarkupId());
      super.onComponentTag(tag);
    }
    
    @Override
    protected void onModelChanged() {
      super.onModelChanged();
      String newValue = (String)getModelObject();
      if (Objects.equals(newValue, oldValue)) return;
      AbstractOntopolyPage page = (AbstractOntopolyPage)getPage();
      FieldInstance fieldInstance = fieldValueModel.getFieldInstanceModel().getFieldInstance();
      if (fieldValueModel.isExistingValue() && oldValue != null)
        fieldInstance.removeValue(oldValue, page.getListener());
      if (newValue != null && !newValue.equals("")) {
        fieldInstance.addValue(newValue, page.getListener());
        fieldValueModel.setExistingValue(newValue);
      }
      oldValue = newValue;
    }      
  };
  textArea.setOutputMarkupId(true);
  add(textArea);
  
  add(new WebComponent("fieldScript") {
    @Override
    protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
      StringBuilder sb = new StringBuilder();
      //sb.append("\ntinyMCE.onLoad();");
      sb.append("\ntinyMCE.execCommand('mceAddControl', true, '" + textArea.getMarkupId() + "');");

      // the next two lines are a work-around for issue 459
      // https://github.com/ontopia/ontopia/issues/459
      // motivated by this posting
      // http://apache-wicket.1842946.n4.nabble.com/tinymce-textarea-in-a-modal-window-not-letting-to-type-td1886534.html
      sb.append("\ntinyMCE.execCommand('mceRemoveControl', false, '" + textArea.getMarkupId() + "');");
      sb.append("\ntinyMCE.execCommand('mceAddControl', true, '" + textArea.getMarkupId() + "');");
      // end of workaround
      
      replaceComponentTagBody(markupStream, openTag, sb.toString());
    }
  });
}
 
Example #7
Source File: ImagePanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param image
 * @return this for chaining.
 */
public ImagePanel addImage(final WebComponent image)
{
  add(this.image = image);
  return this;
}
 
Example #8
Source File: NavigationToolbar.java    From onedev with MIT License 2 votes vote down vote up
/**
 * Factory method used to create the navigator label that will be used by the datatable
 * 
 * @param navigatorId
 *            component id navigator label should be created with
 * @param table
 *            dataview used by datatable
 * @return navigator label that will be used to navigate the data table
 * 
 */
protected WebComponent newNavigatorLabel(final String navigatorId, final DataTable<?, ?> table)
{
	return new NavigatorLabel(navigatorId, table);
}
 
Example #9
Source File: SakaiNavigationToolBar.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Factory method used to create the navigator label that will be used by the datatable
 * 
 * @param navigatorId
 *            component id navigator label should be created with
 * @param table
 *            dataview used by datatable
 * @return navigator label that will be used to navigate the data table
 * 
 */
protected WebComponent newNavigatorLabel(String navigatorId, final DataTable table)
{
	return new SakaiNavigatorLabel(navigatorId, table);
}
 
Example #10
Source File: SakaiNavigationToolBar.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Factory method used to create the navigator label that will be used by the datatable
 * 
 * @param navigatorId
 *            component id navigator label should be created with
 * @param table
 *            dataview used by datatable
 * @return navigator label that will be used to navigate the data table
 * 
 */
protected WebComponent newNavigatorLabel(String navigatorId, final DataTable table)
{
	return new SakaiNavigatorLabel(navigatorId, table);
}