eclipse-ee4j / mojarra-jsf-extensions

Other
1 stars 3 forks source link

Ensure scripts in replacement markup are evaluated prior to postReplace, when appropriate #90

Closed glassfishrobot closed 11 years ago

glassfishrobot commented 16 years ago

if you set the postreplace attribute of an Ajax transaction, the function receives incorrect call parameters:

<?xml version="1.0" encoding="UTF-8"?>

<jsp:root version="2.1" xmlns:df="http://java.sun.com/jsf/dynamicfaces" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">

function pr(a,b,c) { alert(a + " " + b + " " + c); } whatever the button action handler does, the javascript function named pr() receives the 1st and 3rd parameters as null or undefined, making it impossible to use it #### Environment Operating System: All Platform: All #### Affected Versions [current]
glassfishrobot commented 5 years ago
glassfishrobot commented 16 years ago

@glassfishrobot Commented Reported by autozoom

glassfishrobot commented 16 years ago

@glassfishrobot Commented rogerk said: Taking ownership

glassfishrobot commented 16 years ago

@glassfishrobot Commented rogerk said: I'm not familiar with how thw Woodstock components encapsulate the underlying Dynamic Faces javascript apis and.. I haven't used the postReplace function myself but the documentation states:

postReplace

The name of a globally scoped function that conforms to the following signature.

function postReplace(ajaxZone, innerHTML, [closure], [xjson]);

This function is called after the markup replacement for each component that needs to be re-rendered with data from this ajax response. The optional argument closure is whatever was passed as the closure option to the DynaFaces.fireAjaxTransaction or DynaFaces.installDeferredAjaxTransaction that initiated the ajax request for this response. The optional argument xjson is whatever was passed as the xjson option to the DynaFaces.fireAjaxTransaction or DynaFaces.installDeferredAjaxTransaction that initiated the ajax request for this response. The xjson agrument is passed to the server and may have been modified by the server.

An example usage of this in dynamic faces is the jmaki integration. Take a look under: jsf-extensions/trunk/code/run-time/samples/jmaki/src/main/webapp Take a look at: mainColumn.jsp devtime.js

devtime.js has a postReplace function:

function postReplace(ajaxZone, innerHTML) { var isJmaki; if ((isJmaki = (-1 != ajaxZone.id.indexOf("form:table"))))

{ jmaki.clearWidgets(); }

innerHTML.evalScripts(); if (isJmaki)

{ window.onload(); }

}

Seems like the args to your function should be "ajaxZone" and "innerHTML"

glassfishrobot commented 16 years ago

@glassfishrobot Commented autozoom said: I read the documentation and it's pretty clear how it's supposed to work, but it's not working with woodstock components, and woodstock team points me to JSF extension website

glassfishrobot commented 16 years ago

@glassfishrobot Commented rogerk said: Reassinging to Matt at his request.

glassfishrobot commented 16 years ago

@glassfishrobot Commented mattbohm said: Because woodstock is heavily based on JavaScript, currently you must go a little further in your application to ensure that the scripts of woodstock components are evaluated prior to the invocation of your custom postReplace function.

I was able to resolve this by doing two things:

1. Manually replace the jsf-extensions-dynamic-faces-0.1.jar and jsf-extensions-common-0.1.jar inside the dynamicfaces.complib (0.2) with the versions of those jars used in woodstock. (If you are building netbeans from sources, you can find those jars inside visualweb.woodstock.webui.jsf/external/woodstock-components-4.2.zip.)

2. Specify a custom replace function, as shown below, calling markup.evalScripts after DynaFaces.replace:

<?xml version="1.0" encoding="UTF-8"?> <jsp:root version="2.1" xmlns:df="http://java.sun.com/jsf/dynamicfaces" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">

Now the element parameter passed in to customPostReplace is non-null. The closure parameter passed in to customPostReplace is still unpopulated, because we are not passing any closure to the DynaFaces.fireAjaxTransaction call (see [https://jsf-extensions.dev.java.net/nonav/mvn/reference-ajax.html#DynaFaces.fireAjaxTransaction](https://jsf-extensions.dev.java.net/nonav/mvn/reference-ajax.html#DynaFaces.fireAjaxTransaction)). If you do want to use a closure, as, for instance, the Currency Trader sample application does (it does so conditionally), you can specify a closure as follows. The following appears in the poll function in currencytrader.js: DynaFaces.Tx.config.pollTx.closure = ...; ... DynaFaces.Tx.fire('pollTx'); You could emulate this technique, replacing occurrences of pollTx with the name of your AjaxTransaction (for example, tx1). By doing so, the logic in DynaFaces.Tx.fire will pass your closure in when it calls DynaFaces.fireAjaxTransaction. Marking as enhancement, to devise a cleaner way to ensure scripts embedded in the replacement markup are evaluated prior to postReplace, but only when appropriate.
glassfishrobot commented 16 years ago

@glassfishrobot Commented autozoom said: Yes this way it works thanks, I think the trick is that we cannot use a custom postreplace without using a custom replace at the same time. This is the kind of samples and docs we need to effectively use the libraries. thanks

glassfishrobot commented 11 years ago

@glassfishrobot Commented @edburns said: I am no longer tracking progress of these projects on java.net.

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JSF_EXTENSIONS-90

glassfishrobot commented 11 years ago

@glassfishrobot Commented Marked as won't fix on Wednesday, May 29th 2013, 8:24:34 am