JQuery Primefaces remoteCommand parameter issue
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.dreamcatch开发者_StackOverflow社区er.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>
@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);
}
}
In your init() method you call sourceURL, but in your example URL you use scrapeURL. May this be the error?
精彩评论