#779 Bug in generateURL method of StandardXYURLGenerator

1.0.x
closed-invalid
General (896)
5
2007-07-31
2007-07-31
Anonymous
No

Hi,
The following code in version 1.0.6 does not seem to be correct:
public String generateURL(XYDataset dataset, int series, int item) {
String url = this.prefix;
boolean firstParameter = url.indexOf("?") == -1;
url += firstParameter ? "?" : "&";
url += this.seriesParameterName + "=" + series
+ "&" + this.itemParameterName + "=" + item;
return url;
}

Reason: it is not fetching the needed values from the passed daatset and thus the URLs are not generated properly especially when one needs to drill down to other reports based on the values of the current report.

Please replace this code with the following (as this correctly uses the the dataset to get the series key and also the y values which are equivalent to the category in a CategoryDataset):
public String generateURL(XYDataset dataset, int series, int item) {
String url = this.prefix;
Comparable seriesKey = dataset.getSeriesKey(series);
double yValue = dataset.getYValue(series, item);
boolean firstParameter = url.indexOf("?") == -1;
url += firstParameter ? "?" : "&";
url += this.seriesParameterName + "=" + URLUtilities.encode(
seriesKey.toString(), "UTF-8");
url += "&" + this.categoryParameterName + "=" + yValue;
return url;
}

Thanks
Sachin

Discussion

  • Sachin

    Sachin - 2007-07-31

    Logged In: YES
    user_id=1598410
    Originator: NO

    Also please consider this option also:
    public String generateURL(XYDataset dataset, int series, int item) {
    String url = prefix;
    Comparable seriesKey = dataset.getSeriesKey(series);
    double xValue = dataset.getXValue(series, item);
    boolean firstParameter = url.indexOf("?") == -1;
    url += firstParameter ? "?" : "&";
    url += seriesParameterName + "=" + URLUtilities.encode(
    seriesKey.toString(), "UTF-8");
    url += "&" + categoryParameterName + "=" + xValue;
    return url;
    }
    Difference between above and this is that for the categoryParameterName the first code picks the y values and this one picks the x values.
    Probably in the constructor we need to decide whether the url generated should pass the x values or the y values or both for categoryParameterName.

    Thanks
    Sachin

     
  • David Gilbert

    David Gilbert - 2007-07-31
    • assigned_to: nobody --> mungady
    • status: open --> closed-invalid
     
  • David Gilbert

    David Gilbert - 2007-07-31

    Logged In: YES
    user_id=112975
    Originator: NO

    This is not a bug. The URL that is generated uniquely identifies the item by including the series index and the item index - if the actual data values (which may not be unique, since a dataset can certainly have the same x and/or y-values appearing multiple times) are important to you, your server-side code can fetch them directly from the dataset based on the series and item indices. Or, if you prefer, you can create your own *custom* URL generators incorporating the code you've supplied in this bug report...but making those the standard behaviour would be wrong.

     
  • Sachin

    Sachin - 2007-07-31

    Logged In: YES
    user_id=1598410
    Originator: NO

    Hi,
    I understand your case.
    But if you look "Comparable seriesKey = dataset.getSeriesKey(series);" would be unique and also for a series "double xValue = dataset.getXValue(series, item);" would also be unique. yes what may not be unique would be "double yValue = dataset.getYValue(series, item)".

    Further if you have implemented StandardXYURLGenerator without making use of the dataset data, then why is the StandardCategoryURLGenerator implemented picking the values for series and item from the dataset.

    We can gave the same reasoning for the later too as "The URL that is generated uniquely identifies the item by including the series index and the item index."

    Hope I am clear.

    Thanks
    Sachin
    ps: anyway I have implemented my special case using *custom* URL generators

     

Log in to post a comment.