-
1. Re: pass own parameter in modaPanel
ilya_shaikovsky Jun 25, 2007 9:51 AM (in response to jgomes99)You can pass your parameters during modalPanel opening or closing. This passing could be performed in the following way:
Richfaces.showModalPanel('panelId', {left: auto}, {param1: value1});
Thus, except the standard modalPanel parameters you can pass any of your own parameters.
Also modalPanel allows to handle its own opening and closing events on the client side. The "onshow" and "onclose" attributes are used in this case.
The following example shows how on the client side to define opening and closing event handling in such a way that your own parameters could also be obtained:onshow="alert(event.parameters.param1)"
Here, during modalPanel opening the value of a passing parameter is output. -
2. Re: pass own parameter in modaPanel
jgomes99 Jun 25, 2007 11:10 AM (in response to jgomes99)ok, but where put the code onshow??, I use this Richfaces.showModalPanel('panelId', {left: auto}, {param1: value1});
but after I don't now obtain de parameter in the modal panel -
3. Re: pass own parameter in modaPanel
ilya_shaikovsky Jun 26, 2007 7:11 AM (in response to jgomes99)I mean onshow attribute that maay call JS code where this parameters will be available.
-
4. Re: pass own parameter in modaPanel
srilowha Jul 6, 2007 5:32 PM (in response to jgomes99)Do you know if there is any way to call a java backing bean method from 'onshow'? Or is it exclusively JavaScript?
-
5. Re: pass own parameter in modaPanel
sergeysmirnov Jul 6, 2007 5:39 PM (in response to jgomes99)a4j:jsFunction is a component that allow to call whatever you want on the server from javascript
-
6. Re: pass own parameter in modaPanel
cassolato Aug 9, 2007 10:21 AM (in response to jgomes99)Good Morning, this is my firsth post... I'm trying pass parameters, but I'm haven't success. Can you give a sample for me ? tk's.
-
7. Re: pass own parameter in modaPanel
ilya_shaikovsky Aug 9, 2007 11:40 AM (in response to jgomes99)In the developer guide there is an example and many other interesting info.
-
8. Re: pass own parameter in modaPanel
asookazian Dec 12, 2007 1:53 PM (in response to jgomes99)I am having problems implementing the following: passing data from JSF to SFSB on submit of modalPanel using h:inputHidden tags. Here's the code:
xhtml<!-- note and row data submit --> <rich:modalPanel id="mpNoteAndEmployeeSubmit" minHeight="200" minWidth="450" height="500" width="500" zindex="2000" onshow="alert(event.parameters.param1);alert(event.parameters.param2);alert(event.parameters.param3)"> <f:facet name="header"> <a4j:form id="a4jHeaderForm3"> <h:outputText id="headerText3" value=""/> </a4j:form> </f:facet> <a4j:form id="a4jMainForm3"> <h:panelGrid columns="2" style="vertical-align:middle"> <h:outputText id="description3" value=""/> <BR/> <h:inputTextarea id="noteText3" value="#{noteAction.noteText}" rows="6" cols="50"> <a4j:support event="onkeyup" reRender="out3" /> </h:inputTextarea> <h:inputHidden id="rowIndex" value="test1"/> <h:inputHidden id="siteId" value="test2"/> <h:inputHidden id="employeeNumber" value="test3"/> <h:inputHidden id="modalPanelName" value="mpNoteAndEmployeeSubmit"/> <h:panelGroup id="out3"> <a4j:commandButton id="submit3" value="submit" actionListener="#{noteAction.submit}" oncomplete="clickDataTableSubmit();Richfaces.hideModalPanel('mpNoteAndEmployeeSubmit')" rendered="#{not empty noteAction.noteText2}"> </a4j:commandButton> </h:panelGroup> <BR/> <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mpNoteAndEmployeeSubmit');unselectCurrentRadioButton()"/> </h:panelGrid> </a4j:form> </rich:modalPanel>
JS functionfunction setModalFormAttributes(param1, param2, param3) { alert('param1 = ' + param1 + ' param2 = ' + param2 + ' param3 = ' + param3); document.getElementById("a4jMainForm3:rowIndex").value = param1; document.getElementById("a4jMainForm3:siteId").value = param2; document.getElementById("a4jMainForm3:employeeNumber").value = param3; alert('rowIndex = ' + document.getElementById("a4jMainForm3:rowIndex").value); alert('siteId = ' + document.getElementById("a4jMainForm3:siteId").value); alert('employeeNumber = ' + document.getElementById("a4jMainForm3:employeeNumber").value); }
SFSB://submit method called from adminSecurityAudit.xhtml modalPanel a4j:form's public void submit(ActionEvent event) { Map<String, String> map = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); Collection<String> c = map.values(); Iterator<String> it = c.iterator(); while(it.hasNext()) { String val = it.next(); log.info("*** val = " + val); } String rowIndex = map.get("a4jMainForm3:rowIndex"); String siteId = map.get("a4jMainForm3:siteId"); String employeeNumber = map.get("a4jMainForm3:employeeNumber"); String modalPanelName = map.get("a4jMainForm3:modalPanelName"); log.info("*** mapSize = " + map.size()); log.info("rowIndex = " + rowIndex + " *** siteId = " + siteId + " *** employeeNumber = " + employeeNumber); //in the case of yes/no/yes (with user entering selection for adjLimit RB last, check to make sure if the secLevel RB is No. If it's Yes (i.e. yes/yes/yes), don't proceed. if ( !( this.getIcomsAccountApproved() == true && this.getSecurityLevelApproved() == true && this.getAdjustmentLimitApproved() == true ) ) { if ( !modalPanelName.equalsIgnoreCase("mpEmployeeSubmit") ) { // in case of yes/no/yes, prevent insertion of blank note for the 3rd RB (adjLimit) //create a new instance of TblSecurityAuditNote entity bean TblSecurityAuditNote note = new TblSecurityAuditNote(Integer.getInteger(siteId), Integer.getInteger(employeeNumber), colName, noteText, new Date()); //TO DO: remove hard-coding of the name-number mapping Integer colNum = convertColName(colName); Integer rowNum = rowIndex==null?0:Integer.getInteger(rowIndex); //TO DO: add exception handling here in case null or empty string (throw application exception) TblSecurityAuditNote[] myNoteArray = noteList.get(rowNum); myNoteArray[colNum] = note; noteList.set(rowNum, myNoteArray); noteText = ""; } } }
The input hidden values are not being overridden by the JS function (I see the output from the SFSB). They are the original values. I know the JS function works b/c I have a separate button I've tested it with.
What am I doing wrong here?? -
9. Re: pass own parameter in modaPanel
asookazian Dec 12, 2007 1:57 PM (in response to jgomes99)sorry, it was a simple mistake. The onshow attribute of the modalPanel was not calling the JS function...
-
10. Re: pass own parameter in modaPanel
kfletcher2005 Dec 12, 2007 3:08 PM (in response to jgomes99)Did you try..
document.getElementById("mpNoteAndEmployeeSubmit:a4jMainForm3:rowIndex").value = param1;
To get a handle on the hidden field, you may need a more descriptive selector for the id. Do a view source when the page is fully rendered, and find that specific hidden field and look at its id. Your javascript getElementById might need more stuff pre-pended to what you currently have.