Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Routes 'Assign static args' only work for first argument #998

Closed
c-lee8 opened this issue Aug 26, 2016 · 4 comments
Closed

Routes 'Assign static args' only work for first argument #998

c-lee8 opened this issue Aug 26, 2016 · 4 comments
Assignees
Milestone

Comments

@c-lee8
Copy link

c-lee8 commented Aug 26, 2016

Hi Play Framework team,

I am using play 1.2.7.2 (also tested in 1.4.2 which still contains the problem)

I want to assign a specific route to an existing Controller as described in the section: "Assign static args"
https://www.playframework.com/documentation/1.4.x/routes

GET /properties/condos-for-sale App.allResidences(adType:'sale', type:'condo')

However, only the first parameter is sent to the controller, the controller only receives adType with the String value of 'sale', and the type remains as null. If I remove the first argument or swap the position of the two arguments then type will be assigned to 'condo'. But the second argument will remain as null.

Is there a work around or a fix for this? Integrating this back to 1.2 will be great so that our existing app will be less likely to break from the upgrade.

Thank you!
Chin

@xael-fry
Copy link
Member

xael-fry commented Sep 1, 2016

@chinyeelee could you show the declaration of the method allResidences in the controller?
Thanks

@c-lee8
Copy link
Author

c-lee8 commented Sep 1, 2016

@xael-fry Thanks Alexandre, our actual api is rather complicated and beyond the scope of the question, so I simplified the usage. Tested with the following:

    public static void allResidences(String type, String adType){
        System.out.println(type);
        System.out.println(adType);
    }

Using:

GET /properties/condos-for-sale App.allResidences(adType:'sale', type:'condo')

Only the first item, that is adType will have the value 'sale'. type remains as null.

@xael-fry xael-fry self-assigned this Oct 6, 2016
@xael-fry xael-fry added this to the 1.4.4 milestone Oct 6, 2016
@xael-fry
Copy link
Member

xael-fry commented Oct 21, 2016

@chinyeelee, just removed the space after ',' should make it work.
GET /properties/condos-for-sale App.allResidences(adType:'sale',type:'condo')

I will add a fix to avoid this problem for 1.4.x

xael-fry added a commit to xael-fry/play that referenced this issue Oct 21, 2016
xael-fry added a commit that referenced this issue Oct 24, 2016
[#998] fix(router): allow to have space when defining static args in routes
xael-fry added a commit that referenced this issue Oct 25, 2016
…n routes

# Conflicts:
#	framework/src/play/mvc/Router.java
@c-lee8
Copy link
Author

c-lee8 commented Oct 25, 2016

Thank you for the help! @xael-fry

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants