Package javax.portlet

Examples of javax.portlet.PortletPreferences


            editPage = reqEditPage;
        }
       
        if (this.allowPreferences == true)
        {                      
            PortletPreferences prefs = request.getPreferences();

            if (prefs != null && reqEditPage == null)
            {
                editPage = prefs.getValue(PARAM_EDIT_PAGE, this.defaultEditPage);
            }
        }

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


        }
       
        if (this.allowPreferences == true)
        {

            PortletPreferences prefs = request.getPreferences();

            if (prefs != null && reqHelpPage == null)
            {
                helpPage = prefs.getValue(PARAM_HELP_PAGE, this.defaultHelpPage);
            }
        }

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

      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

  }

  public DOMTree getDOMTree( String name, PortletRequest request )
    {
    if ( name == null ) name = "";
    PortletPreferences prefs = request.getPreferences();
    String path = prefs.getValue( name, "" );
        return new DOMTree( name, path );
    }
View Full Code Here

    }
 
  public void saveDOMTree( DOMTree dt, PortletRequest request )
  {
    if ( dt == null ) return ;
    PortletPreferences prefs = request.getPreferences();
    try
    {
      prefs.setValue( dt.getName(), dt.getPath() );
      prefs.store();
    }
    catch ( ReadOnlyException e ) { }
    catch ( IOException e ) { }
    catch ( ValidatorException e ) { }
    }
View Full Code Here

    public String save()
    {
        if (this.date != null)
        {
            PortletRequest request = (PortletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
            PortletPreferences prefs = request.getPreferences();
            try
            {
               
                prefs.setValue(getDateKey(this.date), this.notes);
                prefs.store();
            }
            catch (Exception e)
            {
                System.err.println("error storing prefs " + e);
            }
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

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.