Link to home
Start Free TrialLog in
Avatar of cgray1223
cgray1223

asked on

JQuery Primefaces RemoteCommand Parameter Issue

Hello,

My goal was to call this page with a queryString parameter (http://localhost:8080/page.html?scrapeU ... ://cnn.com and then try to pull the value from the requestparametermap off the facescontext but its null in my init method. My second option is to set an inputhidden in my jQuery(document).ready function but the below syntax doesn't work. Anyone know how to get this to work either way? Thanks for the help!

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:p="http://primefaces.prime.com.tr/ui"
   xmlns:dc="http://dc.dreamcatcher.com/facelet-taglib">
<ui:composition template="/WEB-INF/facelet/layout/external/main.xhtml">
   <ui:define name="content">
   <h:form id="scrapeFrm" binding="#{bookmarklet.bookmarkletFrm}">
   <h:inputHidden id="scrapeURL" value="default"/>
   <p:remoteCommand name="scapeImages" process="@this,scrapeURL" actionListener="#{bookmarklet.loadImages}" update="imageGrid"/>
   <script type="text/javascript">
       jQuery(document).ready(function(){
          alert("here");
          var value=$('#scrapeURL').val();
          alert(value);
          scapeImages();
       }); 
    </script>
    </h:form>
   </ui:define>
</ui:composition>
</html>

Open in new window

@Named
@Scope("request")
public class Bookmarklet extends BaseAction{
   private UIForm bookmarkletFrm;
   
   public void init(){
       if (!FacesUtils.isPostback()) {
          ExternalContext context = FacesUtils.getExternalContext();
          String scrapeURL = context.getRequestParameterMap().get("sourceURL");
          bookmarkletBean.setScrapeURL(scrapeURL);
       }
    }

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of cmalakar
cmalakar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial