hi,
i'm unable to retrieve the value from the DropdownListBox,
here is the code im using
<hbj:dropdownListBox id="stage" selection="IOR" onSelect="select" width="80">
<hbj:listBoxItem key="HI" value="Impact Asessment " />
<hbj:listBoxItem key="ME" value="IOR " />
<hbj:listBoxItem key="LO" value="Estimation Time " />
<hbj:listBoxItem key="WL" value="Technical Spec " />
</hbj:dropdownListBox>
actually i want to get the value i.e.,"Impact Assesment", "Estimation Time".......
i 've tried with this code but its returning null
DropdownListBox DD = (DropdownListBox) getComponentByName("stage");
response.write(DD.getTextForKey(DD.getSelection()));
help me to get the value
thanks in advance
regards,
Kiran
Message was edited by: JOSHUA KIRAN
best is you download PDK:
public class DropDownListBoxExample extends PageProcessorComponent {
public DynPage getPage() {
return new MyDynPage();
}
// JSPDynPage
public class MyDynPage extends JSPDynPage {
DropDownListBoxBean myBean;
/*
Used for user initialization. called when the application is started
*/
public void doInitialization() {
// Get the request, context and profile from portal platform
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
IPortalComponentProfile myProfile = myContext.getProfile();
// Initialization of bean
DropDownListBoxBean myBean = new DropDownListBoxBean();
setBeanFromProfile(myProfile, myBean);
// Put the bean into the application context
myContext.putValue("myBeanName", myBean);
}
/*
Used for handling the input. Generally called each time
after doInitialization
*/
public void doProcessAfterInput() throws PageException {
// Get the request, context and profile from portal platform
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
IPortalComponentProfile myProfile = myContext.getProfile();
// Get the bean from application context
myBean = (DropDownListBoxBean) myContext.getValue("myBeanName");
setBeanFromProfile(myProfile, myBean);
}
/*
Used for handling the output. This method is always called.
*/
public void doProcessBeforeOutput() throws PageException {
// set the name of your JSP page
setJspName("dropdownlistbox.jsp");
}
public void onSelect(Event event) throws PageException {
// do something with the event.
}
private void setBeanFromProfile(IPortalComponentProfile myProfile, DropDownListBoxBean myBean) {
myBean.setBoxWidth(myProfile.getProperty("width"));
myBean.setTooltip(myProfile.getProperty("tooltip"));
myBean.setSelection(myProfile.getProperty("selection"));
myBean.setDisabled(myProfile.getProperty("disabled"));
myBean.setItemText(myProfile.getProperty("ItemsFromJSP"));
myBean.setItemSelected(myProfile.getProperty("ItemSelected"));
// add items to model
DefaultListModel myModel = myBean.getModel();
myModel.addItem(myProfile.getProperty("ItemsFromModel"), myProfile.getProperty("ItemsFromModel"));
myBean.setModel(myModel);
}
}
}
-
<%--- DropdownListBox.jsp --%>
<%@ taglib uri="tagLib" prefix="hbj" %>
<hbj:content id="myContext" >
<hbj:page title="dropdownListBox tag">
<H1>dropdownListBox tag sample</H1>
<hbj:form>
Simple DropdownListBox (preselected by item):<br><br>
<hbj:dropdownListBox id="myDropdownListBox1"
tooltip="Tooltip for my DropdownListBox"
disabled="false"
>
<hbj:listBoxItem key="k1" value="red"/>
<hbj:listBoxItem key="k2" value="yellow"/>
<hbj:listBoxItem key="k3" value="blue" selected="true"/>
</hbj:dropdownListBox>
<br><br>Simple DropdownListBox:(preselected by DropdownListBox)<br><br>
<hbj:dropdownListBox id="myDropdownListBox2"
tooltip="Tooltip for my DropdownListBox"
selection="k2"
disabled="false">
<hbj:listBoxItem key="k1" value="red"/>
<hbj:listBoxItem key="k2" value="yellow"/>
<hbj:listBoxItem key="k3" value="blue"/>
</hbj:dropdownListBox>
</hbj:form>
</hbj:page>
</hbj:content>
-
package bean;
import com.sapportals.htmlb.DefaultListModel;
// Bean for dataexchange between DynPage and JSP
public class DropDownListBoxBean {
public DefaultListModel model;
public String tooltip;
public String selection;
public String boxWidth;
public String disabled;
public String itemText;
public String itemSelected;
public String getSelection() {
return selection;
}
public void setSelection(String selection) {
this.selection = selection;
}
public DefaultListModel getModel() {
return model;
}
public void setModel(DefaultListModel model) {
this.model = model;
}
public String getTooltip() {
return tooltip;
}
public void setTooltip(String tooltip) {
this.tooltip = tooltip;
}
public String getBoxWidth() {
return boxWidth;
}
public void setBoxWidth(String boxWidth) {
this.boxWidth = boxWidth;
}
public String isDisabled() {
return disabled;
}
public void setDisabled(String disabled) {
this.disabled = disabled;
}
public String getItemText() {
return itemText;
}
public void setItemText(String itemText) {
this.itemText = itemText;
}
public String isItemSelected() {
return itemSelected;
}
public void setItemSelected(String itemSelected) {
this.itemSelected = itemSelected;
}
// constructor
public DropDownListBoxBean() {
this.model = new DefaultListModel();
this.model.setSingleSelection(true);
}
}
Add a comment