[
https://issues.apache.org/jira/browse/PLUTO-575?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ate Douma resolved PLUTO-575.
-----------------------------
Fix Version/s: 2.0.2
2.1.0
Resolution: Fixed
Fixes committed.
Nice catch Allan and thanks for providing the fixes.
> Javascript fails to correctly clear out select boxes
> ----------------------------------------------------
>
> Key: PLUTO-575
> URL: https://issues.apache.org/jira/browse/PLUTO-575
> Project: Pluto
> Issue Type: Bug
> Components: portlets-admin
> Affects Versions: 2.0.0
> Environment: Windows/Mac IE and Firefox were tested.
> Reporter: Allan Jackson
> Assignee: Ate Douma
> Priority: Minor
> Fix For: 2.0.2, 2.1.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The javascript functions that are called when the value of the page select
> box and the portlet select box are changed fail to correctly clear out the
> options presented to the user. This can result in trying to add a portlet
> that doesn't exist for the specified context, or the user may try to remove a
> portlet from a page that doesn't actually contain that portlet.
> The problem stems from two issues in the following code:
> for(var i = 0; i < portletsSelectBox.options.length;i++) {
> portletsSelectBox.options[i] = null;
> }
> 1: As the loop executes, the value of portletsSelectBox.options.length goes
> down, so the loop does not execute the correct number of times. This results
> in some elements not being deleted.
> 2: Each time an option is removed from the portletsSelectBox.options, the
> entire array is reindexed. So if you delete the element at positon 0, the
> item in position 1 moves to location 0. This results in this item never
> being deleted.
> These errors occur on both the select box for the pages and the box for the
> portlets. In each instance, the error may be fixed through the use of a
> while loop as demonstrated below.
> In function <portlet:namespace/>doSwitchPage(select), replace the following
> code:
> for(var i=0; i < placePortletsSelect.options.length;i++) {
> placePortletsSelect.options[i] = null;
> }
> with this code:
> while (placePortletsSelect.options.length > 0) {
> placePortletsSelect.options[0] = null;
> }
> And in function <portlet:namespace/>doSwitch(select), replace the following
> code:
> for(var i = 0; i < portletsSelectBox.options.length;i++) {
> portletsSelectBox.options[i] = null;
> }
> with this code:
> while (portletsSelectBox.options.length > 0) {
> portletsSelectBox.options[0] = null;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.