on 03-26-2007 2:43 PM
How would I capture the dropdown box's selected item and pass it on to a java script function that actually raises EPCF.raiseEvent()?
Am using following code:
<script language="javascript">
function raiseEvent()
{
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var dropdown = eval(func("ddListName"));
var name = dropdown.getValue();
EPCM.raiseEvent("urn:com.epcf.EPCFProducer", "objid",dropdown.getValue());
}
</script>
<hbj:dropdownListBox
id="ddListName" width="150"
model="TESTBEAN.model"
selection="<%=TESTBEAN.getItemText()%>"
onClientSelect="JavaScript:raiseEvent();"
>
</hbj:dropdownListBox>
And in second iView:
<script>
function eventHandler(event)
{
myFormId.data.value=event.dataObject;
}
EPCM.subscribeEvent("urn:com.epcf.EPCFProducer", "objid", eventHandler);
</script>
<form id="myFormId" >
The string passed is:
<input type="text" value="" name="data"/>
</form>
Can anybody correct my code or suggest me appropriateway to do it??
Regards,
Vaibhav
HI Vaibhav,
I would suggest you go through the documentation on EPCF given at help.sap.com. The url is: <a href="http://help.sap.com/saphelp_nw04/helpdata/en/ce/3e98408d953154e10000000a1550b0/frameset.htm">Client-Side Eventing</a>.
Also, to transfer data through EPCF, use EPCM.storeClientData and EPCM.loadClientData. These are explained in the Client Data Bag API under the link I have provided above.
Also, check if you are getting the selected value in the raiseEvent method. This can be done by adding an 'alert' in the method before calling the EPCM.raiseEvent method.
Hope this helps you.
Regards
Ranjith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
it would help to know what errors you get.
To start, I'd replace the dropdown with:
<hbj:dropdownListBox
id="ddListName" width="150"
model="TESTBEAN.model"
selection="<%=TESTBEAN.getItemText()%>"
jsObjectNeeded="TRUE"
onClientSelect="raiseEvent()"
>
</hbj:dropdownListBox>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Now am able to pass value. But it is passing integer values that is index values, but I want value assigned to that index to be pass.
Like,
DefaultListModel modelListName;
modelListName = new DefaultListModel();
modelListName.setSingleSelection(true);
modelListName.addItem("-1","SELECT");
modelListName.addItem("1","Vaibhav1");
modelListName.addItem("2","Vaibhav2");
modelListName.addItem("3","Vaibhav3");
modelListName.addItem("4","Vaibhav4");
modelListName.addItem("5","Vaibhav5");
modelListName.addItem("6","Vaibhav6");
modelListName.setSelection("1");
myBean.setModel(modelListName);
For 1, it should pass "Vaibhav1".
What change should i make in dropdown.getValue() ?
Hi,
try changing your script instead:
<script language="javascript">
function raiseEvent()
{
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var dropdown = eval(func("ddListName"));
var name = dropdown.getValue();
var selText = <%=TESTBEAN.getTextForKey(name)%>;
EPCM.raiseEvent("urn:com.epcf.EPCFProducer", "objid", selText);
}
</script>
I've been thinking and I don't think what I proposed will work.
Try this instead:
<script language="javascript">
var listVals = new Array();
<%
for (int i=0; i < TESTBEAN.model.size; i++){
%>
listVals[<%=i%>] = "<%=TESTBEAN.model.getTextByIndex<i>%>";
<%}%>
function raiseEvent()
{
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var dropdown = eval(func("ddListName"));
var name = dropdown.getValue();
var index = dropdown.getIndex();
EPCM.raiseEvent("urn:com.epcf.EPCFProducer", "objid", listVals[index]);
}
</script>
Bean file:
/*
Created on Mar 23, 2007
*
To change the template for this generated file go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.epcf;
import com.sapportals.htmlb.DefaultListModel;
/**
@author m1005192
*
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
public class DropDownListBoxBean
{
String ItemText = "";
public DefaultListModel model;
StringBuffer strMessage = new StringBuffer();
public String message = "";
/**
@return
*/
public String getItemText() {
return ItemText;
}
/**
@param string
*/
public void setItemText(String string) {
ItemText = string;
}
/**
@return
*/
public DefaultListModel getModel() {
return model;
}
/**
@param model
*/
public void setModel(DefaultListModel model) {
this.model = model;
}
/**
@return
*/
public StringBuffer getStrMessage() {
return strMessage;
}
/**
@param buffer
*/
public void setStrMessage(StringBuffer buffer) {
strMessage = buffer;
buffer.append("Vaibhav");
}
/**
@return
*/
public String getMessage() {
strMessage.append(message);
return message;
}
/**
@param string
*/
public void setMessage(String string) {
message = string;
}
}
What happens? It throws some javascript error?
There is another easier way that is not as pretty but that should work. Define your model like this:
DefaultListModel modelListName;
modelListName = new DefaultListModel();
modelListName.setSingleSelection(true);
modelListName.addItem("-1","SELECT");
modelListName.addItem("Vaibhav1","Vaibhav1");
modelListName.addItem("Vaibhav2","Vaibhav2");
modelListName.addItem("Vaibhav3","Vaibhav3");
modelListName.addItem("Vaibhav4","Vaibhav4");
modelListName.addItem("Vaibhav5","Vaibhav5");
modelListName.addItem("Vaibhav6","Vaibhav6");
modelListName.setSelection("Vaibhav1");
myBean.setModel(modelListName);
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.