Solved

JQuery Primefaces RemoteCommand Parameter Issue

Posted on 2011-03-20
1
2,327 Views
Last Modified: 2012-06-21
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


0
Comment
Question by:cgray1223
1 Comment
 
LVL 23

Accepted Solution

by:
cmalakar earned 500 total points
ID: 35699082
>> My second option is to set an inputhidden in my jQuery(document).ready function but the below syntax doesn't work.

What is not working ? Did you get alert () ?

I dont see you including the jquery js file.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now