Java Code Examples for org.apache.wicket.util.string.StringValue#isNull()

The following examples show how to use org.apache.wicket.util.string.StringValue#isNull() . 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: AbstractBpmnProcessResource.java    From syncope with Apache License 2.0 5 votes vote down vote up
protected BpmnProcess getBpmnProcess(final Attributes attributes) {
    StringValue modelId = attributes.getRequest().getQueryParameters().getParameterValue(Constants.MODEL_ID_PARAM);

    BpmnProcess bpmnProcess = modelId == null || modelId.isNull()
            ? null
            : BpmnProcessRestClient.getDefinitions().stream().
                    filter(object -> modelId.toString().equals(object.getModelId())).findAny().orElse(null);
    if (bpmnProcess == null) {
        throw new NotFoundException("BPMN process with modelId " + modelId);
    }

    return bpmnProcess;
}
 
Example 2
Source File: HelloDbResponse.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private byte[] getDataFromDatabase(final StringValue queriesParam, final int queries)
    throws SQLException, JsonProcessingException
{
  final ThreadLocalRandom random = ThreadLocalRandom.current();
  DataSource dataSource = WicketApplication.get().getDataSource();
  World[] worlds = new World[queries];
  try (Connection connection = dataSource.getConnection())
  {
    try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM World WHERE id = ?",
        ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
    {
      for (int i = 0; i < queries; i++)
      {
        statement.setInt(1, random.nextInt(DB_ROWS) + 1);
        try (ResultSet resultSet = statement.executeQuery())
        {
          resultSet.next();
          worlds[i] = new World(resultSet.getInt("id"), resultSet.getInt("randomNumber"));
        }
      }
    }
  }

  byte[] data;
  if (queriesParam.isNull())
  {
    // request to /db should return JSON object
    data = HelloJsonResponse.MAPPER.writeValueAsBytes(worlds[0]);
  }
  else
  {
    // request to /db?queries=xyz should return JSON array (issue #648)
    data = HelloJsonResponse.MAPPER.writeValueAsBytes(worlds);
  }
  return data;
}
 
Example 3
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static boolean contains(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  if (sval == null) {
    return false;
  } else {
    return sval.isNull() == false;
  }
}
 
Example 4
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static String getAsString(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return null;
  } else {
    return sval.toString();
  }
}
 
Example 5
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static Integer getAsInteger(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return null;
  } else {
    return sval.toInteger();
  }
}
 
Example 6
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static int getAsInt(final PageParameters parameters, final String name, final int defaultValue)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return defaultValue;
  } else {
    return sval.toInt();
  }
}
 
Example 7
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static Long getAsLong(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return null;
  } else {
    return sval.toLong();
  }
}
 
Example 8
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static Boolean getAsBooleanObject(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return null;
  } else {
    return sval.toBooleanObject();
  }
}
 
Example 9
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static boolean getAsBoolean(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return false;
  } else {
    return sval.toBoolean();
  }
}
 
Example 10
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static Object getAsObject(final PageParameters parameters, final String name, final Class< ? > type)
{
  final StringValue sval = parameters.get(name);
  if (sval == null || sval.isNull() == true) {
    return null;
  } else {
    return sval.to(type);
  }
}
 
Example 11
Source File: GradebookPage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response) {
	super.renderHead(response);

	final String version = PortalUtils.getCDNQuery();

	// Drag and Drop/Date Picker (requires jQueryUI)
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js%s", version)));

	// Include Sakai Date Picker
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/library/js/lang-datepicker/lang-datepicker.js%s", version)));

	// tablesorted used by student grade summary
	response.render(JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter')", null));
	response.render(
			JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter/2.27.7/dist/css/theme.bootstrap.min.css')", null));

	//Feedback reminder for instructors
	response.render(
			JavaScriptHeaderItem.forScript("includeWebjarLibrary('awesomplete')", null));

	// GradebookNG Grade specific styles and behaviour
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-grades.css%s", version)));
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-gbgrade-table.css%s", version)));
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-sorter.css%s", version)));
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-print.css%s", version), "print"));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-grade-summary.js%s", version)));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-update-ungraded.js%s", version)));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-sorter.js%s", version)));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-connection-poll.js%s", version)));

	final StringValue focusAssignmentId = getPageParameters().get(FOCUS_ASSIGNMENT_ID_PARAM);
	final StringValue showPopupForNewItem = getPageParameters().get(NEW_GBITEM_POPOVER_PARAM);
	if(!showPopupForNewItem.isNull() && !focusAssignmentId.isNull()){
		getPageParameters().remove(FOCUS_ASSIGNMENT_ID_PARAM);
		getPageParameters().remove(NEW_GBITEM_POPOVER_PARAM);
		response.render(JavaScriptHeaderItem
				.forScript(
						String.format("GbGradeTable.focusColumnForAssignmentId(%s,%s)", focusAssignmentId.toString(),showPopupForNewItem),
						null));
	}
}
 
Example 12
Source File: GradebookPage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response) {
	super.renderHead(response);

	final String version = PortalUtils.getCDNQuery();

	// Drag and Drop/Date Picker (requires jQueryUI)
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js%s", version)));

	// Include Sakai Date Picker
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/library/js/lang-datepicker/lang-datepicker.js%s", version)));

	// tablesorted used by student grade summary
	response.render(JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter')", null));
	response.render(
			JavaScriptHeaderItem.forScript("includeWebjarLibrary('jquery.tablesorter/2.27.7/dist/css/theme.bootstrap.min.css')", null));

	//Feedback reminder for instructors
	response.render(
			JavaScriptHeaderItem.forScript("includeWebjarLibrary('awesomplete')", null));

	// GradebookNG Grade specific styles and behaviour
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-grades.css%s", version)));
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-gbgrade-table.css%s", version)));
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-sorter.css%s", version)));
	response.render(CssHeaderItem
			.forUrl(String.format("/gradebookng-tool/styles/gradebook-print.css%s", version), "print"));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-grade-summary.js%s", version)));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-update-ungraded.js%s", version)));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-sorter.js%s", version)));
	response.render(JavaScriptHeaderItem
			.forUrl(String.format("/gradebookng-tool/scripts/gradebook-connection-poll.js%s", version)));

	final StringValue focusAssignmentId = getPageParameters().get(FOCUS_ASSIGNMENT_ID_PARAM);
	final StringValue showPopupForNewItem = getPageParameters().get(NEW_GBITEM_POPOVER_PARAM);
	if(!showPopupForNewItem.isNull() && !focusAssignmentId.isNull()){
		getPageParameters().remove(FOCUS_ASSIGNMENT_ID_PARAM);
		getPageParameters().remove(NEW_GBITEM_POPOVER_PARAM);
		response.render(JavaScriptHeaderItem
				.forScript(
						String.format("GbGradeTable.focusColumnForAssignmentId(%s,%s)", focusAssignmentId.toString(),showPopupForNewItem),
						null));
	}
}
 
Example 13
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public static boolean hasParameter(final PageParameters parameters, final String name)
{
  final StringValue sval = parameters.get(name);
  return sval != null && sval.isNull() == false;
}