Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use method syntax for linkTo #78

Closed
lucascs opened this issue Sep 18, 2013 · 16 comments
Closed

Use method syntax for linkTo #78

lucascs opened this issue Sep 18, 2013 · 16 comments
Milestone

Comments

@lucascs
Copy link
Member

lucascs commented Sep 18, 2013

Since everyone will use Servlet 3.0, we could support something like:

${linkTo[SomeController].method(arg1, arg2)}

@csokol
Copy link
Contributor

csokol commented Sep 18, 2013

Totally agree!
Em 17/09/2013 22:14, "Lucas Cavalcanti" notifications@github.com escreveu:

Since everyone will use Servlet 3.0, we could support something like:

${linkTo[SomeController].method(arg1, arg2)}


Reply to this email directly or view it on GitHubhttps://github.com//issues/78
.

@mariofts
Copy link
Member

THIS.

@garcia-jj
Copy link
Member

Sounds like great.

@lucascs
Copy link
Member Author

lucascs commented Sep 18, 2013

It's a pity that it won't work with void methods =( Not with this syntax, anyway

@garcia-jj
Copy link
Member

But you will return a fake object, and not the real instance of method controller.

@leocwolter
Copy link
Contributor

I don't know if it's possible, but if it's not:
As an alternative, couldn't it be something like linkTo(myController.method(arg1, arg2))?
I guess it would be much easier to implement
(Something like Mockito.when(mock.method()) )

@lucascs
Copy link
Member Author

lucascs commented Sep 18, 2013

Think of this invocation in java:

class MyController {
    public void method() {...}
}

linkTo(myController.method()); //compilation error

@leocwolter
Copy link
Contributor

myController would be a proxy of MyController. The proxy handler would just save the method invocation(method's name + parameters) and the linkTo()(or linker.linkTo()) would return the path based on the method invocation.
Oh, I see, It won't work with void a method also, sorry.

@garcia-jj
Copy link
Member

Lucas, Leonardo is right, because we don't wanna execute the method, but only create a link. So a proxy is better solution.

@lucascs
Copy link
Member Author

lucascs commented Sep 18, 2013

I have another idea. Because of this line:

https://github.com/caelum/vraptor4/blob/master/vraptor-core/src/main/java/br/com/caelum/vraptor/ioc/ControllerHandler.java#L71

we can use ${TestController} and it returns the BeanClass associated to this controller. My idea is return a decorator for beanClass in which we can call ${TestController.method}, and it returns the correspondent ControllerMethod.

so we can change the API to something like:

${linkTo(TestController.method)}, if we don't want to add args, or
${linkTo(TestController.method, arg1, arg2)} if we want to add args.

What do you think?

@Turini
Copy link
Member

Turini commented Sep 18, 2013

I think it would be great =)

@leocwolter
Copy link
Contributor

I'm curious about the implementation :D

On Wednesday, September 18, 2013, Rodrigo Turini wrote:

I think it would be great =)


Reply to this email directly or view it on GitHubhttps://github.com//issues/78#issuecomment-24659263
.

@mariofts
Copy link
Member

The first version, with the @garcia-jj idea of using proxy/fake objects isn't viable?

@lucascs
Copy link
Member Author

lucascs commented Sep 18, 2013

No. We cannot proxy void.class ;) And most of controller methods will be void.

@garcia-jj
Copy link
Member

#143

@lucascs
Copy link
Member Author

lucascs commented Sep 30, 2013

Closed by #143

@lucascs lucascs closed this as completed Sep 30, 2013
@Turini Turini added this to the 4.0.0-beta-1 milestone Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants