-
1. Re: Setting value to a param through javascript
gonorrhea Apr 28, 2009 12:43 AM (in response to msantana)Not sure if you really need the <f:param> tag.
Have you tried @RequestParameter annotation for the h:inputHidden element?
Specifies that a component attribute is to be injected with the value of a request parameter.
Basic type conversions are performed automatically.• value — specifies the name of the request parameter. Default to the name of the
component attribute.ex:
@RequestParameter private String cantidadProductoId;
-
2. Re: Setting value to a param through javascript
mcalpay Apr 28, 2009 10:23 AM (in response to msantana)you should use something like;
<s:button onclick="document.getElementById('cantidadProductoId').value"
js should assign/manipulate whatever f:param is rendered to
cheers
-
3. Re: Setting value to a param through javascript
msantana Apr 28, 2009 2:44 PM (in response to msantana)Hey! thank you Arbi, but i think that i have tried that without success. But i will try again.
Thank you very much for your support! -
4. Re: Setting value to a param through javascript
msantana Apr 28, 2009 2:46 PM (in response to msantana)Yes i tried that but it passes the String instead of the input hidden value.
Thanx dude for your support
-
5. Re: Setting value to a param through javascript
cosmo Apr 28, 2009 3:42 PM (in response to msantana)As Arbi said, why don't you simply use the java variable asociated with cantidadProductoId in your addProductoAComprar method?
BTW, I think you don't need the @RequestParameter. Just <h:inputHidden id="cantidadProductoId" value="#{carrito.cantidadProductoId}" /> should work.
If you choose this approach, remember that s:button does not sumbit the form, so you may need to use a h:commandButton instead.
-
6. Re: Setting value to a param through javascript
msantana Apr 29, 2009 7:33 PM (in response to msantana)Ok, i will try to exaplin in a better way the scenario:
I have a grid which has products. It has a column which has a a:commandButton, this button has an attribute onComplete wich shows a modalPanel.
The idea is, I select a product and the system ask me for an amount, then i enter the amount, and press ok.
The main page has two grids: one who shows all the products registered, and other below who shows the products i selected and entered the amount,.So, in the a:commandButton i show the modalPanel, but i have in the modal panel, a input hidden which has the id of that product, by setting it through JavaScript on the attribute onclick of the commandbutton:
Then in the modalPanel when i click Ok, i have to add the product, into the collection refered by the grid below with the amount entered.So i have this code:
The column of the first grid:
<rich:column styleClass="action"> <f:facet name="header">Acciones</f:facet> <a:commandButton value="Comprar" id="comprar" image="/img/fam/basket_add.png" title="Comprar" oncomplete="#{rich:component('cantidadPanel')}.show()" reRender="importeTotal, productosAComprar" onclick="document.getElementById('cantidadProductoId').value=#{producto.productoId}"> </a:commandButton> </rich:column>
The modal panel:
<rich:modalPanel id="cantidadPanel" width="350" height="100"> <f:facet name="header"> <h:panelGroup> <h:outputText value="Cantidad a comprar"></h:outputText> </h:panelGroup> </f:facet> <f:facet name="controls"> <h:panelGroup> <h:inputHidden id="cantidadProductoId" value="" /> <h:graphicImage value="/img/close.png" styleClass="hidelink" id="hidelink"/> <rich:componentControl for="cantidadPanel" attachTo="hidelink" operation="hide" event="onclick"/> </h:panelGroup> </f:facet> <s:label>Cantidad</s:label><rich:inputNumberSpinner value="1" minValue="0" label="Cantidad"/>   <s:button id="btnCantidad" value="Aceptar" action="#{carrito.addProductoAComprar}"> <f:param name="producto" value=""/> </s:button> </rich:modalPanel>
So, i want on the action of the s:button add the product by passing the productId and the amount entered in the inputNumberSpinner.
I read your replies and i have to ask the way, if a put in carrito, a @RequestParamenter cantidadProductoId, how to set it when i pressed the a:commandButton, because i have to set it there. If i do that i can dispense of the inputhidden because i have that value on the seam entity.
I hope this, can help you to help me, because i really need to do this.
Thank you very much to all of you people!!! You really rock!!!
-
7. Re: Setting value to a param through javascript
joblini May 1, 2009 5:49 AM (in response to msantana) -
8. Re: Setting value to a param through javascript
msantana May 1, 2009 6:37 AM (in response to msantana)YES!!! I think that is the component i was missing!!!!
Thank you so much dude!!!!
You really rock man!!! -
9. Re: Setting value to a param through javascript
msantana May 1, 2009 5:20 PM (in response to msantana)It is the component but i have got the same as before!,
I put this:<a:actionparam noEscape="true" name="producto" value="document.getElementById('cantidadProductoId').value"/>
But on the bean i put:
new Long(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("producto"));
And i´ve got: document.getElementById('cantidadProductoId').value, instead of the real value.
What i´m missing now?
-
10. Re: Setting value to a param through javascript
msantana Jun 9, 2009 3:43 PM (in response to msantana)Anyone who has a tip? I really need that.
I am only trying to pass through a parameter, the value of the inputHidden like i wrote before. But instead of that i've got: 'document.getElementById('cantidadProductoId').value' . That string instead of the value of that.
Thanx in advice!.