Package javax.portlet

Examples of javax.portlet.PortletPreferences


      viewPage = reqViewPage;
    }
   
        if (this.allowPreferences == true)
        {
            PortletPreferences prefs = request.getPreferences();

           
            if (prefs != null && reqViewPage == null)
            {
                viewPage = prefs.getValue(PARAM_VIEW_PAGE, this.defaultViewPage);
            }         
        }

        if (viewPage != null)
        {
View Full Code Here


     * Save the prefs
     */
    public void processPreferencesAction(ActionRequest request, ActionResponse actionResponse)
    throws PortletException, IOException
    {
        PortletPreferences prefs = request.getPreferences();
        PreferencesHelper.requestParamsToPreferences(request);
        prefs.store();
        actionResponse.setPortletMode(PortletMode.VIEW);
    }
View Full Code Here

    protected TestResult checkPreferenceValidator(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure the validator catches invalid preferences.");
        result.setSpecPLT("14.4");
       
        PortletPreferences preferences = request.getPreferences();
        if (LOG.isDebugEnabled()) {
          LOG.debug("Original preferences:");
          logPreferences(preferences);
        }
        boolean exceptionThrown = false;
        try {
            preferences.setValue("TEST", " Spaces removed by trim ");
            if (LOG.isDebugEnabled()) {
              LOG.debug("Modified VALIDATION_TEST_KEY preference:");
              logPreferences(preferences);
            }
            // Call store() method to invoke the validator.
            preferences.store();
           
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
          return result;
         
        } catch (IOException ex) {
          TestUtils.failOnException("Unable to store preference value.", ex, result);
          return result;
         
        } catch (ValidatorException ex) {
          // We are expecting this exception!
            exceptionThrown = true;
            // FIXME: what is going on below?
            try {
              //get rid of spaces because it causes problems with reset() call.
                preferences.setValue("TEST", "OK");
              preferences.reset("TEST");
            } catch (Throwable th) {
              LOG.error(th);             
            }
        }
       
View Full Code Here

        TestResult result = new TestResult();
        result.setDescription("Ensure only one validator instance is created "
            + "per portlet definition.");
        result.setSpecPLT("14.4");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValue(
                PreferencesValidatorImpl.CHECK_VALIDATOR_COUNT,
                "true");
            // Call store() method to invoke the validator.
            preferences.store();
            result.setReturnCode(TestResult.PASSED);
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
        } catch (IOException ex) {
          TestUtils.failOnException("Unable to store preference value.", ex, result);
        } catch (ValidatorException ex) {
          TestUtils.failOnException("Unable to store preference value.", ex, result);
        } finally {
          try {
            preferences.reset(PreferencesValidatorImpl.CHECK_VALIDATOR_COUNT);
            preferences.store();
          } catch (Exception ex) {
            TestUtils.failOnException("Unable to reset preference value for "
                + PreferencesValidatorImpl.CHECK_VALIDATOR_COUNT,
                ex, result);
          }
View Full Code Here

    protected TestResult checkStorePreferences(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure storage works for portlet preferences.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        if (LOG.isDebugEnabled()) {
          LOG.debug("Preferences to store: " + preferences);
        }
       
        boolean setOccured = false;
        boolean storeOccured = false;
       
        try {
          // Set new value for preference "dummyName".
            preferences.setValue(PREF_NAME, NEW_VALUE);
            String value = preferences.getValue(PREF_NAME, DEF_VALUE);
            if (NEW_VALUE.equals(value)) {
                setOccured = true;
            }
            // Store the preference and get value.
            preferences.store();
            value = preferences.getValue(PREF_NAME, DEF_VALUE);
            if (NEW_VALUE.equals(value)) {
                storeOccured = true;
            }
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
          return result;
        } catch (ValidatorException ex) {
          TestUtils.failOnException("Unable to store preference value.", ex, result);
          return result;
        } catch(IOException ex) {
          TestUtils.failOnException("Unable to store preference value.", ex, result);
          return result;
        } finally {
            // Reset preference to default value, and store!
          try {
            preferences.reset(PREF_NAME);
            preferences.store();
          } catch (Exception ex) {
              TestUtils.failOnException("Unable to set preference value.", ex, result);
              return result;
          }
        }
View Full Code Here

      TestResult result = new TestResult();
      result.setDescription("Ensure proper default is returned when "
          + "a non-existing/value-undefined preference is requested.");
      result.setSpecPLT("14.1");
     
      PortletPreferences preferences = request.getPreferences();
      String value =  preferences.getValue(preferenceName, DEF_VALUE);
      String[] values = preferences.getValues(preferenceName,
                                              new String[] { DEF_VALUE });
      if (DEF_VALUE.equals(value)
          && values != null && values.length == 1
          && DEF_VALUE.equals(values[0])) {
        result.setReturnCode(TestResult.PASSED);
View Full Code Here

        TestResult result = new TestResult();
        result.setDescription("Ensure that preferences defined "
            + "in the deployment descriptor may be retrieved.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        String value = preferences.getValue(PREF_NAME, DEF_VALUE);
        if (value != null && value.equals(PREF_VALUE)) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, PREF_VALUE, result);
        }
View Full Code Here

    protected TestResult checkSetPreferenceSingleValue(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure a single preference value can be set.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValue("TEST", "TEST_VALUE");
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
            return result;
        }
       
        String value = preferences.getValue("TEST", DEF_VALUE);
        if (value != null && value.equals("TEST_VALUE")) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, "TEST_VALUE", result);
        }
View Full Code Here

    protected TestResult checkSetPreferenceMultiValues(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure multiple preference values can be set.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValues("TEST", new String[] {"ONE", "ANOTHER"});
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference values.", ex, result);
          return result;
        }

        String[] values = preferences.getValues("TEST", new String[] { DEF_VALUE });
        if (values != null && values.length == 2
            && values[0].equals("ONE") && values[1].equals("ANOTHER")) {
          result.setReturnCode(TestResult.PASSED);
        } else if (values == null) {
          TestUtils.failOnAssertion("preference values",
View Full Code Here

    protected TestResult checkSetPreferenceNull(PortletRequest request) {
        TestResult result = new TestResult();
        result.setDescription("Ensure a preference value can be set to null.");
        result.setSpecPLT("14.1");
       
        PortletPreferences preferences = request.getPreferences();
        try {
            preferences.setValue("TEST", null);
        } catch (ReadOnlyException ex) {
          TestUtils.failOnException("Unable to set preference value.", ex, result);
            return result;
        }
       
        String value = preferences.getValue("TEST", DEF_VALUE);
        if (DEF_VALUE.equals(value)) {
          result.setReturnCode(TestResult.PASSED);
        } else {
          TestUtils.failOnAssertion("preference value", value, DEF_VALUE, result);
        }
View Full Code Here

TOP

Related Classes of javax.portlet.PortletPreferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.