List of usage examples for org.apache.wicket.util.string StringValue isNull
public boolean isNull()
From source file:org.apache.isis.viewer.wicket.model.common.PageParametersUtils.java
License:Apache License
/** * Creates a new instance of PageParameters that preserves some special request parameters * which should propagate in all links created by Isis * * @return a new PageParameters instance *//* w w w .j a v a 2 s.c o m*/ public static PageParameters newPageParameters() { final PageParameters newPageParameters = new PageParameters(); final RequestCycle cycle = RequestCycle.get(); if (cycle != null) { final IPageRequestHandler pageRequestHandler = PageRequestHandlerTracker.getFirstHandler(cycle); final PageParameters currentPageParameters = pageRequestHandler.getPageParameters(); if (currentPageParameters != null) { final StringValue noHeader = currentPageParameters.get(ISIS_NO_HEADER_PARAMETER_NAME); if (!noHeader.isNull()) { newPageParameters.set(ISIS_NO_HEADER_PARAMETER_NAME, noHeader.toString()); } final StringValue noFooter = currentPageParameters.get(ISIS_NO_FOOTER_PARAMETER_NAME); if (!noFooter.isNull()) { newPageParameters.set(ISIS_NO_FOOTER_PARAMETER_NAME, noFooter.toString()); } } } return newPageParameters; }
From source file:org.apache.syncope.client.console.resources.AbstractWorkflowResource.java
License:Apache License
protected WorkflowDefinitionTO getWorkflowDefinition(final Attributes attributes) { final StringValue modelId = attributes.getRequest().getQueryParameters() .getParameterValue(Constants.MODEL_ID_PARAM); WorkflowDefinitionTO workflowDefinition = modelId == null || modelId.isNull() ? null : restClient.getDefinitions().stream() .filter(object -> modelId.toString().equals(object.getModelId())).findAny().orElse(null); if (workflowDefinition == null) { throw new NotFoundException("Workflow definition with modelId " + modelId); }//from w ww .j a v a 2 s .c o m return workflowDefinition; }
From source file:org.devgateway.toolkit.forms.wicket.page.user.EditUserPage.java
License:Open Source License
@Override protected void onInitialize() { Person person = SecurityUtil.getCurrentAuthenticatedPerson(); if (!SecurityUtil.isCurrentUserAdmin()) { if (person.getId() != getPageParameters().get(WebConstants.PARAM_ID).toLong()) { setResponsePage(getApplication().getHomePage()); }/* w w w . jav a 2s . co m*/ } super.onInitialize(); userName.required(); userName.getField().add(new UsernamePatternValidator()); StringValue idPerson = getPageParameters().get(WebConstants.PARAM_ID); if (!idPerson.isNull()) { userName.getField().add(new UniqueUsernameValidator(idPerson.toLong())); } else { userName.getField().add(new UniqueUsernameValidator()); } userName.setIsFloatedInput(true); editForm.add(userName); MetaDataRoleAuthorizationStrategy.authorize(userName, Component.ENABLE, SecurityConstants.Roles.ROLE_ADMIN); firstName.required(); firstName.setIsFloatedInput(true); editForm.add(firstName); lastName.required(); lastName.setIsFloatedInput(true); editForm.add(lastName); email.required(); email.getField().add(EmailAddressValidator.getInstance()); if (!idPerson.isNull()) { email.getField().add(new UniqueEmailAddressValidator(idPerson.toLong())); } else { email.getField().add(new UniqueEmailAddressValidator()); } email.setIsFloatedInput(true); editForm.add(email); title.setIsFloatedInput(true); editForm.add(title); group.required(); group.setIsFloatedInput(true); editForm.add(group); MetaDataRoleAuthorizationStrategy.authorize(group, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); editForm.add(defaultDashboard); MetaDataRoleAuthorizationStrategy.authorize(defaultDashboard, Component.ENABLE, SecurityConstants.Roles.ROLE_ADMIN); roles.required(); roles.getField().setOutputMarkupId(true); roles.setIsFloatedInput(true); editForm.add(roles); MetaDataRoleAuthorizationStrategy.authorize(roles, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); // stop resetting the password fields each time they are rendered password.getField().setResetPassword(false); cpassword.getField().setResetPassword(false); if (SecurityUtil.isCurrentUserAdmin() && !SecurityUtil.isUserAdmin(compoundModel.getObject()) && idPerson.isNull()) { // hide the change password checkbox and set it's model to true compoundModel.getObject().setChangePass(true); changePass.setVisibilityAllowed(false); } else { compoundModel.getObject().setChangePass(compoundModel.getObject().getChangePassword()); password.getField().setEnabled(compoundModel.getObject().getChangePassword()); cpassword.getField().setEnabled(compoundModel.getObject().getChangePassword()); } changePass.setIsFloatedInput(true); editForm.add(changePass); password.getField().add(new PasswordPatternValidator()); password.setOutputMarkupId(true); password.setIsFloatedInput(true); editForm.add(password); cpassword.setOutputMarkupId(true); cpassword.setIsFloatedInput(true); editForm.add(cpassword); editForm.add(new EqualPasswordInputValidator(password.getField(), cpassword.getField())); enabled.setIsFloatedInput(true); editForm.add(enabled); MetaDataRoleAuthorizationStrategy.authorize(enabled, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); changePassword.setIsFloatedInput(true); editForm.add(changePassword); MetaDataRoleAuthorizationStrategy.authorize(changePassword, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); MetaDataRoleAuthorizationStrategy.authorize(deleteButton, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN); }
From source file:org.efaps.ui.wicket.components.date.DateTimePanel.java
License:Apache License
/** * Method to get for the parameters returned from the form as a datetimes. * * @param _date date//from ww w . j ava 2 s. c o m * @param _hour hour * @param _minute minutes * @param _ampm am/pm * @return valid string * @throws EFapsException on error */ public List<DateTime> getDateList(final List<StringValue> _date, final List<StringValue> _hour, final List<StringValue> _minute, final List<StringValue> _ampm) throws EFapsException { final List<DateTime> ret = new ArrayList<>(); if (_date != null) { Iterator<StringValue> hourIter = null; Iterator<StringValue> minuteIter = null; Iterator<StringValue> ampmIter = null; if (_hour != null) { hourIter = _hour.iterator(); } if (_minute != null) { minuteIter = _minute.iterator(); } if (_ampm != null) { ampmIter = _ampm.iterator(); } for (final StringValue date : _date) { if (!date.isNull() && !date.isEmpty()) { final DateTimeFormatter fmt = DateTimeFormat .forPattern(this.converter.getDatePattern(Context.getThreadContext().getLocale())) .withChronology(Context.getThreadContext().getChronology()); fmt.withLocale(getLocale()); final MutableDateTime mdt = fmt.parseMutableDateTime(date.toString()); if (hourIter != null) { final StringValue hourStr = hourIter.next(); final int hour = Integer.parseInt(hourStr.toString("0")); mdt.setHourOfDay(hour); if (ampmIter != null) { final StringValue ampmStr = ampmIter.next(); if ("am".equals(ampmStr.toString("am"))) { if (hour == 12) { mdt.setHourOfDay(0); } } else { if (hour != 12) { mdt.setHourOfDay(hour + 12); } } } if (minuteIter != null) { final StringValue minuteStr = minuteIter.next(); final int minute = Integer.parseInt(minuteStr.toString("0")); mdt.setMinuteOfHour(minute); } } ret.add(mdt.toDateTime()); } } } return ret; }
From source file:org.efaps.ui.wicket.components.footer.AjaxSubmitCloseBehavior.java
License:Apache License
/** * Method checking if the mandatory field of the Form are filled with a value, * and if not opens a WarnDialog and marks the fields in the Form via Ajax. * * @param _target RequestTarget used for this Request * @return true if all mandatory fields are filled, else false *//*w ww .j a v a 2 s. c o m*/ private boolean checkForRequired(final AjaxRequestTarget _target) { AjaxSubmitCloseBehavior.LOG.trace("entering checkForRequired"); boolean ret = true; if (!(getForm().getParent().getDefaultModel() instanceof TableModel)) { final IRequestParameters parameters = getComponent().getRequest().getRequestParameters(); final List<FormPanel> panels = getFormPanels(); for (final FormPanel panel : panels) { for (final Entry<String, Label> entry : panel.getRequiredComponents().entrySet()) { final StringValue value = parameters.getParameterValue(entry.getKey()); if (value.isNull() || value.isEmpty()) { final Label label = entry.getValue(); label.add(AttributeModifier.replace("class", "eFapsFormLabelRequiredForce")); _target.add(label); ret = false; } } } if (!ret) { showDialog(_target, "MandatoryDialog", false, false); } } return ret; }
From source file:org.efaps.ui.wicket.components.split.AjaxStorePositionBehavior.java
License:Apache License
/** * On request the values are stored./*from w w w . ja va 2 s . c om*/ * * @param _target AjaxRequestTarget */ @Override protected void respond(final AjaxRequestTarget _target) { final StringValue horizontal = getComponent().getRequest().getRequestParameters() .getParameterValue(AjaxStorePositionBehavior.PARAMETER_HORIZONTALPOSITION); final StringValue verticalTmp = getComponent().getRequest().getRequestParameters() .getParameterValue(AjaxStorePositionBehavior.PARAMETER_VERTICALPOSITION); if (!horizontal.isNull()) { Configuration.setAttribute(ConfigAttribute.SPLITTERPOSHORIZONTAL, horizontal.toString()); } if (!verticalTmp.isNull()) { Configuration.setAttribute(ConfigAttribute.SPLITTERPOSVERTICAL, verticalTmp.toString()); } }
From source file:org.hippoecm.frontend.plugins.ckeditor.AutoSaveBehavior.java
License:Apache License
@Override protected void respond(final AjaxRequestTarget target) { final Request request = RequestCycle.get().getRequest(); final IRequestParameters requestParameters = request.getPostParameters(); final StringValue data = requestParameters.getParameterValue(POST_PARAM_DATA); if (data.isNull()) { log.info("Cannot auto-save CKEditor contents because the request parameter '{}' is missing", POST_PARAM_DATA);//from w w w . j a va2 s . co m } else { log.debug("Auto-saving CKEditor contents: '{}'", data); editorModel.setObject(data.toString()); } }
From source file:org.hippoecm.frontend.plugins.cms.root.ParameterInUrlController.java
License:Apache License
protected Map<String, String> getParametersMap(IRequestParameters requestParameters) { final StringValue paramsValue = requestParameters.getParameterValue(URL_PARAMETERS); Map<String, String> parameters = new HashMap<>(); if (!paramsValue.isNull() && !paramsValue.isEmpty()) { final String value = paramsValue.toString(); try {//ww w .j av a 2s .c om final JSONObject jsonObject = new JSONObject(new JSONTokener(value)); final Iterator keys = jsonObject.keys(); while (keys.hasNext()) { final String next = (String) keys.next(); parameters.put(next, jsonObject.getString(next)); } } catch (JSONException e) { throw new RuntimeException("Unable to parse parameters from '" + value + "'", e); } } return parameters; }
From source file:org.hippoecm.frontend.plugins.yui.layout.WireframeBehavior.java
License:Apache License
@Override protected void respond(AjaxRequestTarget target) { final RequestCycle requestCycle = RequestCycle.get(); StringValue position = requestCycle.getRequest().getRequestParameters().getParameterValue("position"); if (!position.isNull()) { final String strPos = position.toString(); if (!Strings.isEmpty(strPos)) { onToggleFromClient(strPos, toggle(strPos)); }/*from w w w. j a v a2s . co m*/ } }
From source file:org.hippoecm.frontend.plugins.yui.tree.TreeBehavior.java
License:Apache License
@Override protected void respond(AjaxRequestTarget target) { final RequestCycle requestCycle = RequestCycle.get(); StringValue action = requestCycle.getRequest().getRequestParameters().getParameterValue("action"); StringValue uuid = requestCycle.getRequest().getRequestParameters().getParameterValue("UUID"); if (action.isNull() || uuid.isNull() || uuid.toString().length() == 0) { return;//from w ww.j av a 2s .c o m } if (action.toString().equals("click")) { onClick(target, uuid.toString()); } else if (action.toString().equals("dblClick")) { onDblClick(target, uuid.toString()); } }