I have a gallery component that loads thumbnails in a <ui:repeat> control.
Now when I click on the thumbnail, I need to call a bean method, but with a parameter (in this case the image ID to retreive the image details)
In all samples, a textinput is used which is bound to a bean property, but in this case I will need to set the property directly through javascript.
Anyone who can point me to the right direction?
Thanks a lot
Best practice to send parameters to RemoteCommand
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
I think you need to use the client side api instead of remoteCommand. User's Guide has a section on how to use PrimeFaces.ajax.* javascript api. Third parameter of this function takes a parameters as a javascript hash. You can use it to send custom parameters.
p:remoteCommand also supports f:param tag, but it will be created once with those specific parameters and not possible to change it. So using javascript api directly would be easy.
p:remoteCommand also supports f:param tag, but it will be created once with those specific parameters and not possible to change it. So using javascript api directly would be easy.
If I would want to use the javascript api, how could I then know what the URL for an bean method is?
I have a page where I have an SVG graphics and I want to do drag and drop. So I have java script running which detects the drop, but I don't know how to notify a bean of the value selected. I would then also have to set a value on the bean so that I know which object was dropped where.
I have a page where I have an SVG graphics and I want to do drag and drop. So I have java script running which detects the drop, but I don't know how to notify a bean of the value selected. I would then also have to set a value on the bean so that I know which object was dropped where.
Primefaces 2.0.2
Mojarra JSF 2.0.2-FCS
Tomcat 6.0.26
Mojarra JSF 2.0.2-FCS
Tomcat 6.0.26
- kwintesencja
- Posts: 316
- Joined: 08 Feb 2010, 20:33
- Location: Brazil
Hi there,
i do need to pass parameter via javascript to remoteCommand, how can i do that?
here some code:
thanks in advance;
i do need to pass parameter via javascript to remoteCommand, how can i do that?
here some code:
Code: Select all
<script type="text/javascript">
function onload() {
var x = someParamReturnedByAnotherFunction;
lazyLoad(x);//here i want to pass the param to remoteCommand
}
</script>
<p:remoteCommand name="lazyload" update="lazypanel" action="#{managedBean.test(param)}">
</p:remoteCommand>
Managed Bean
public class managedBean{
public void test(string x) {
System.out.println(x);
}
}
thanks in advance;
Att,
--
Rafael Mauricio Pestano
Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework
Blog
@realpestano
--
Rafael Mauricio Pestano
Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework
Blog
@realpestano
- kwintesencja
- Posts: 316
- Joined: 08 Feb 2010, 20:33
- Location: Brazil
can anyone tell me if its possible:
the mbean method is not being called, and no js errors are displayed in firebug.
using PF 3.0M2, Mojarra 2.1
Code: Select all
function startApplet() {
var x = "test"
lazyload({param:x});
}
<p:remoteCommand name="lazyload" update="lazypanel" actionListener="#{authenticationController.test}"/>
mbean
public void test(ActionEvent event) {
String param = (String) event.getComponent().getAttributes().get("param");
System.out.println(param );
}
using PF 3.0M2, Mojarra 2.1
Att,
--
Rafael Mauricio Pestano
Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework
Blog
@realpestano
--
Rafael Mauricio Pestano
Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework
Blog
@realpestano
Hi kwintesencja,
A few days back I was looking out for a similar solution. Though I could find out a way to pass parameters into remoteCommand but I figured out a way, (from BalusC's blog) that you could use a hidden input field submit that was set by javascript and hence pass your parameter from js to JSF. My code for this follows:-
I would really appreciate if someone can look at this and kindly let us know, if this is the best way to pass parameters from js to JSF.
A few days back I was looking out for a similar solution. Though I could find out a way to pass parameters into remoteCommand but I figured out a way, (from BalusC's blog) that you could use a hidden input field submit that was set by javascript and hence pass your parameter from js to JSF. My code for this follows:-
I would really appreciate if someone can look at this and kindly let us know, if this is the best way to pass parameters from js to JSF.
Code: Select all
<script>
function prepareForShowingDetails(idOfSelected) {
document.getElementById('selectedItemId_in').value = idOfSelected; //setting the hidden input field with the parameter required to be passed .....
showDetails(); // calling remoteCommand to show the content details
}
</script>
<h:form prependId="false" >
<h:inputHidden id="selectedItemId_in" value="#{list.selected}"/>
<p:remoteCommand name="showDetails" process="selectedItemId_in" update="detailsPanel" oncomplete="detailsDialog.show()"/>
</h:form>
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8
****************************
Using Primefaces 3.4 Snapshot with JSF(Myfaces) 2.1.8
****************************
-
- Information
-
Who is online
Users browsing this forum: No registered users and 12 guests