se vc consegue buscar por nome, faça isso então, ao invés de passar o objectid…
daí vc passa só um ?nome=nomeDoCara na requisição que já era.
se vc consegue buscar por nome, faça isso então, ao invés de passar o objectid…
daí vc passa só um ?nome=nomeDoCara na requisição que já era.
E o que eu vou tentar fazer … e se liga, tu sabe como enviar mais de 1 parametro no ajax?? tem um exemplo ai? valeu
sim, só usar o data:
$.ajax( {
//...
data: {
param1: ....,
param2: ...,
param3:....
}
});
da forma que voce esta fazendo, nao vai chegar “produto” no controler, o que vai chega é “id” com os parametros que voce colocou.
Esse "produto = " não tá servindo de nada. Só você ver: var e = {w: prod = {a:1}}; console.log(JSON.stringify(e));
O resultado é: “{“w”:{“a”:1}}”, onde está o "prod = "? 
Se eu digitar console.log(prod), ele está lá, porém isso não está sendo enviado pelo ajax. Se voce quer receber produto lá, deveria colocar produto.id.inc, produto.id.machine, …
[quote=fabioebner]Tentei fazer o seguinte:
$.ajax({
type: "post",
data: produto = {
"id.inc": product.cdProduct._inc,
"id.machine": product.cdProduct._machine,
"id.new": product.cdProduct._new,
"id.time": product.cdProduct._time
},
dataType: "json",
url: 'http://localhost:8080/noname/productStore/addProductStores',
success: function(data) {
$('.result').html(data);
alert('Load was performed.');
}
});
e o metodo
@Post
@Get
@Path("productStore/addProductStores")
public void addProductStores(ObjectId produto) throws Exception{
abrirConexao();
}
e recebi o seguinte erro:
[quote]
GRAVE: Servlet.service() for servlet [default] in context with path [/noname] threw exception
br.com.caelum.vraptor.http.InvalidParameterException: Exception when trying to instantiate Target(name=produto, type=class org.bson.types.ObjectId)
at br.com.caelum.vraptor.http.iogi.VRaptorInstantiator.handleException(VRaptorInstantiator.java:95)
at br.com.caelum.vraptor.http.iogi.VRaptorInstantiator.instantiate(VRaptorInstantiator.java:87)
at br.com.caelum.vraptor.http.iogi.VRaptorInstantiator.instantiate(VRaptorInstantiator.java:80)
at br.com.caelum.vraptor.http.iogi.IogiParametersProvider.instantiateOrAddError(IogiParametersProvider.java:80)
at br.com.caelum.vraptor.http.iogi.IogiParametersProvider.instantiateParameters(IogiParametersProvider.java:73)
at br.com.caelum.vraptor.http.iogi.IogiParametersProvider.getParametersFor(IogiParametersProvider.java:63)
at br.com.caelum.vraptor.interceptor.ParametersInstantiatorInterceptor.getParametersFor(ParametersInstantiatorInterceptor.java:126)
at br.com.caelum.vraptor.interceptor.ParametersInstantiatorInterceptor.intercept(ParametersInstantiatorInterceptor.java:83)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:59)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:44)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:91)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Paranamer were not able to find your parameter names for public org.bson.types.ObjectId(byte[])You must compile your code with debug information (javac -g) or register another name provider. Try to use br.com.caelum.vraptor.http.DefaultParameterNameProvider instead.
at br.com.caelum.vraptor.http.ParanamerNameProvider.parameterNamesFor(ParanamerNameProvider.java:60)
at br.com.caelum.vraptor.http.iogi.VRaptorParameterNamesProvider.lookupParameterNames(VRaptorParameterNamesProvider.java:29)
at br.com.caelum.iogi.reflection.ClassConstructor.(ClassConstructor.java:24)
at br.com.caelum.iogi.reflection.Target.constructors(Target.java:114)
at br.com.caelum.iogi.ObjectInstantiator.instantiate(ObjectInstantiator.java:30)
at br.com.caelum.iogi.MultiInstantiator.instantiate(MultiInstantiator.java:20)
at br.com.caelum.vraptor.http.iogi.VRaptorInstantiator.instantiate(VRaptorInstantiator.java:85)
… 42 more
[/quote][/quote]