You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Isabel Martínez <im...@seidor.es> on 2014/11/27 12:09:06 UTC

Sling Models to inject RequestParameter

Hi,
I want to develop a Model adaptable form SlingHttpServletRequest “@Model(adaptables={SlingHttpServletRequest.class})”, and inject a parameter from the slingRequest (RequestParameter  getRequestParameter(java.lang.String name) to a java parameter “@Inject RequestParameter requestParameter;” but I haven’t found the correct way to do it. This parameter it’s send via Ajax’s call with a GET method.

Can somebody help me? It’s possible to get this type of parameters in a sling model or I have to get the parameter from de request directly.

Regards,



Isabel Martínez
http://www.seidor.es
[cid:imagee570ca.JPG@e27fe604.4aba501b]<http://www.facebook.com/Seidor>[cid:imageec0f5b.JPG@9d1f3279.42824c2d]<http://www.twitter.com/Seidor>[cid:imagecaac67.JPG@56ffb42d.489d6b91]<http://www.linkedin.com/company/seidor>
        [cid:image5fc66b.JPG@039161e8.4eb207ec]

Tel:    +34 902 995 374
        Pujades, 350 2ª
Edificio Inbisa 22@
08019 Barcelona
España

 [cid:image4c7a9f.GIF@f9366ea3.4e85d907]        Antes de imprimir este mensaje, asegúrese de que sea imprescindible. Proteger el medio ambiente está a nuestro alcance.


[cid:imagee4572f.JPG@b079a93d.4d8bbb6d]



La información que contiene este correo electrónico es confidencial y compete exclusivamente al destinatario. Si Vd ha recibido esta comunicación por error, por favor, notifíquelo inmediatamente al remitente y borre el mensaje junto con sus ficheros anexos sin leerlo, copiarlo, grabarlo, distribuirlo o divulgarlo o hacer cualquier otro uso de la información sin el consentimiento de la empresa. El correo electrónico vía Internet no permite asegurar la confidencialidad o correcta recepción de los mensajes, por lo que la Empresa no asume responsabilidad alguna por los daños causados.

The information contained in this communication is confidential, may be privileged and is intended for the exclusive use of the above named addressee. If you receive this communication in error, please notify the sender immediately and delete it, and all its attached documents. If you are not the intended recipient, you are expressly prohibited from reading, copying, distributing, disseminating or, in any other way, using any of the information without the company consent. Please note that Internet e-mail guarantees neither the confidentiality nor the proper receipt of the message sent, so that the Company shall not be liable for any damages caused.

RE: Sling Models to inject RequestParameter

Posted by Stefan Seifert <ss...@pro-vision.de>.
hello isabel.

it think this is not possible out-of-the box.
you can inject request attributes, but not request parameters - available injectors: [1]

but it would by fairly easy to write your own custom injector [2] for this usecase and register it via OSGi.

stefan

[1] http://sling.apache.org/documentation/bundles/models.html#available-injectors
[2] http://sling.apache.org/documentation/bundles/models.html#custom-injectors

>-----Original Message-----
>From: Isabel Martínez [mailto:imartinez@seidor.es]
>Sent: Thursday, November 27, 2014 12:09 PM
>To: users@sling.apache.org
>Subject: Sling Models to inject RequestParameter
>
>Hi,
>I want to develop a Model adaptable form SlingHttpServletRequest
>“@Model(adaptables={SlingHttpServletRequest.class})”, and inject a parameter
>from the slingRequest (RequestParameter  getRequestParameter(java.lang.String
>name) to a java parameter “@Inject RequestParameter requestParameter;” but I
>haven’t found the correct way to do it. This parameter it’s send via Ajax’s
>call with a GET method.
>
>Can somebody help me? It’s possible to get this type of parameters in a sling
>model or I have to get the parameter from de request directly.
>
>Regards,
>
>Isabel Martínez
>http://www.seidor.es
>
>
>
>
>
>
>Tel:
>+34 902 995 374
>
>Pujades, 350 2ª
>Edificio Inbisa 22@
>08019 Barcelona
>España
>
>
>Antes de imprimir este mensaje, asegúrese de que sea imprescindible. Proteger
>el medio ambiente está a nuestro alcance.
>
>
>
>
>
>La información que contiene este correo electrónico es confidencial y compete
>exclusivamente al destinatario. Si Vd ha recibido esta comunicación por error,
>por favor, notifíquelo inmediatamente al remitente y borre el mensaje junto
>con sus ficheros anexos sin leerlo, copiarlo, grabarlo, distribuirlo o
>divulgarlo o hacer cualquier otro uso de la información sin el consentimiento
>de la empresa. El correo electrónico vía Internet no permite asegurar la
>confidencialidad o correcta recepción de los mensajes, por lo que la Empresa
>no asume responsabilidad alguna por los daños causados.
>The information contained in this communication is confidential, may be
>privileged and is intended for the exclusive use of the above named addressee.
>If you receive this communication in error, please notify the sender
>immediately and delete it, and all its attached documents. If you are not the
>intended recipient, you are expressly prohibited from reading, copying,
>distributing, disseminating or, in any other way, using any of the information
>without the company consent. Please note that Internet e-mail guarantees
>neither the confidentiality nor the proper receipt of the message sent, so
>that the Company shall not be liable for any damages caused.