Weather Portlet
  1. Weather Portlet
  2. WPT-83

Editing location to Celsius does not stick

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1.4
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When editing an existing location to use Celsius rather than Fahrenheit, that change does not stick.

      Screencast.

      Locally tracked in MyUW project as MUMMNG-1910

        Activity

        Hide
        Benito J. Gonzalez added a comment -

        Hi Andrew,

        I am using version 1.1.5-SNAPSHOT. I was not able to reproduce this issue. Persisting a change in units worked. It is saved in Portlet Preferences. Here is the code:

        public void saveLocations(List<SavedLocation> savedLocations, PortletPreferences prefs) {
        final List<String> locationCodes = new ArrayList<String>(savedLocations.size());
        final List<String> locations = new ArrayList<String>(savedLocations.size());
        final List<String> metrics = new ArrayList<String>(savedLocations.size());

        for (final SavedLocation savedLocation : savedLocations)

        { locationCodes.add(savedLocation.code); locations.add(savedLocation.name); metrics.add(savedLocation.temperatureUnit.toString()); }

        try

        { prefs.setValues(LOCATION_CODES, locationCodes.toArray(new String[locationCodes.size()])); prefs.setValues(LOCATIONS, locations.toArray(new String[locations.size()])); prefs.setValues(UNITS, metrics.toArray(new String[metrics.size()])); prefs.reset(METRICS); //Clear value, handling legacy preferences structure prefs.store(); }


        catch (ReadOnlyException roe)

        { throw new PermissionDeniedDataAccessException("Failed to save preferences due to one being marked read-only. The portlet preferences locationCode, locations, and metrics must not be read only.", roe); }


        catch (ValidatorException ve)

        { throw new DataIntegrityViolationException("Validation of saved locations preferences failed", ve); }


        catch (IOException ioe)

        { throw new RuntimeException("Failed to store saved locations preferences due to IO error", ioe); }

        }

        I checked the database and found the values persisting with my limited test.

        Show
        Benito J. Gonzalez added a comment - Hi Andrew, I am using version 1.1.5-SNAPSHOT. I was not able to reproduce this issue. Persisting a change in units worked. It is saved in Portlet Preferences. Here is the code: public void saveLocations(List<SavedLocation> savedLocations, PortletPreferences prefs) { final List<String> locationCodes = new ArrayList<String>(savedLocations.size()); final List<String> locations = new ArrayList<String>(savedLocations.size()); final List<String> metrics = new ArrayList<String>(savedLocations.size()); for (final SavedLocation savedLocation : savedLocations) { locationCodes.add(savedLocation.code); locations.add(savedLocation.name); metrics.add(savedLocation.temperatureUnit.toString()); } try { prefs.setValues(LOCATION_CODES, locationCodes.toArray(new String[locationCodes.size()])); prefs.setValues(LOCATIONS, locations.toArray(new String[locations.size()])); prefs.setValues(UNITS, metrics.toArray(new String[metrics.size()])); prefs.reset(METRICS); //Clear value, handling legacy preferences structure prefs.store(); } catch (ReadOnlyException roe) { throw new PermissionDeniedDataAccessException("Failed to save preferences due to one being marked read-only. The portlet preferences locationCode, locations, and metrics must not be read only.", roe); } catch (ValidatorException ve) { throw new DataIntegrityViolationException("Validation of saved locations preferences failed", ve); } catch (IOException ioe) { throw new RuntimeException("Failed to store saved locations preferences due to IO error", ioe); } } I checked the database and found the values persisting with my limited test.

          People

          • Assignee:
            Benito J. Gonzalez
            Reporter:
            Andrew Petro
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: