Hi all,
I'm tryng to use Jersey, but I have some problems with sub resources.
My resources are User and Url and I want get by array id a url associated to
user.
The main class is:
public class UserResource {
@HttpMethod
@UriTemplate("user/{key}/")
public User getUser(@UriParam("key")
String key) {
return new UserDAO().findByUser(key);
}
}
while class User is:
public class User{
/*constructor set and get methods
...
*/
private Set<Urls> urls = new HashSet<Urls>();
@HttpMethod
@UriTemplate("url/{keyUrl}/")
public Urls getUrl(@UriParam("keyUrl")
int keyUrl) {
Url url = null;
if (this.getUrls() != null) {
url = (Url)this.getUrls().toArray()[keyUrl];
}
return url;
}
}
}
and class Url is:
public class Url{
/*constructor set and get methods
...
*/
}
If I try to access to
http://localhost/user/jesty the service works well,
but if i tryng to access to
http://localhost/user/jesty/url/0 the method
called is only getUser with key: "jesty/url/0" without calling getUrl after.
How can I do?
Thanks,
Davide
--
Email.it, the professional e-mail, gratis per te:
http://www.email.it/f
Sponsor:
250 biglietti da visita Gratis + 42 modelli e Etichette per Indirizzo
Gratis + Porta biglietti Gratis -Offerta limitata!
Clicca qui:
http://adv.email.it/cgi-bin/foclick.cgi?mid=6783&d=20070713