Solved

JQuery Primefaces RemoteCommand Parameter Issue

Posted on 2011-03-20
1
2,376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bitwise and to sum elements 2 52
Natural height and jquery 6 40
Make qty change inside array as well 1 20
What does this method description mean? 1 14
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

738 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