call super(parameters) in the page constructor
then getPage().getParameters() should have the parameter map
johan
On Mon, Aug 11, 2008 at 5:51 PM, Ryan O'Hara <[EMAIL PROTECTED]> wrote:
> We are trying to figure out the best way to make our URLs portable.
> Currently, we mount a QueryStringUrlEncodingStrategy in our application
> class. Then, in the beginning of the page's constructor, page parameters
> are mapped to instance variables. Then, when the form button is clicked, a
> map of parameters is created to pass to setResponsePage(Class,
> PageParameters). It seems like mapping the parameters to variables and
> creating a map of parameters to setResponsePage() can be avoided by using
> setResponsePage(this.getPage()), but the URL produced is not portable.
> Having to map parameters to instance variables and maintain a map to pass
> in is high maintenance. Is there a better way to do this? Thanks for the
> help.
>
> Ryan
>
> public Search(PageParameters params) {
> //TODO:
> //it would be nice if this could be done automatically...
> //if there are parameters, map them to instance variables
> if (params.size() > 0) {
> setSourceSelection(params.getString("source"));
> setPosition(params.getString("position"));
> setSizeStart(params.getString("sizeStart"));
> setSizeEnd(params.getString("sizeEnd"));
> setSnpStart(params.getString("snpStart"));
> setSnpEnd(params.getString("snpEnd"));
> setSortorderSelection(params.getString("sortorder"));
> setVariationTypeSelection(params.getString("variationType"));
>
> if (params.getInt("pagesize", -1) != -1) {
> setPagesize(params.getInt("pagesize"));
> }
>
> //populate the result list now that the instance
> //variables have been set
> try {
> resultlist =
> annotatedQuery.getAnnotations(getSourceSelection(), getPosition(),
> getSizeStart(), getSizeEnd(), getSnpStart(), getSnpEnd(),
> getSortorderSelection(), getVariationTypeSelection());
> } catch (CnvException e) {
> e.printStackTrace();
> error(e.getMessage());
> }
> }
>
> //submit button
> Button asl = new Button("submit") {
> public void onSubmit() {
> try {
> //TODO:
> //it would be nice if we could make the url of
> //setresponsepage(this.getPage()) to look nice
> //as it would handle all of the parameter business.. ugh
> HashMap params = new HashMap<String, String>();
> params.put("source", getSourceSelection());
> params.put("position", getPosition());
> params.put("sortorder", getSortorderSelection());
> params.put("variationType",
> getVariationTypeSelection());
> if (getSizeStart() != null) {
> params.put("sizeStart", getSizeStart());
> }
> if (getSizeEnd() != null) {
> params.put("sizeEnd", getSizeEnd());
> }
> if (getSnpStart() != null) {
> params.put("snpStart", getSnpStart());
> }
> if (getSnpEnd() != null) {
> params.put("snpEnd", getSnpEnd());
> }
> setPagesize((Integer) results_page.getModelObject());
> params.put("pagesize", getPagesize().toString());
>
> System.out.println(getSortorderSelection());
> setResponsePage(Search.class, new
> PageParameters(params));
> } catch (Exception e) {
> error(e.getMessage());
> }
> }
> };
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>