How to add several item to HashMap?
I want to add more than one item to HashMap When I click the "submit" and I want to made a Shopping cart.But I can't add several item to the HashMap.It will clear the content that I added to it When I click the second time.Anyone have good idea?
Mycode is://///////////////////////////////////////////////////////////////////
<select name="item" size="3" multiple>
<option value="jsp">jsp</option>
<option value="asp">asp</option>
<option value="PHP">PHP</option>
</select>
</p>
<input type="text" name="itemnumber">
<p>
<input type="submit" name="Submit" value="submit">
</p>
</form>
<%
String item="asp";
item=request.getParameter("item");
String itemnum="1";
itemnum=request.getParameter("itemnumber");
int itemn=(Integer.valueOf(itemnum)).intValue();
out.println("Your select is:"+item);
out.println("Item number is:"+itemnum);
HashMap cart;
cart=new HashMap();
cart.put(item,new Integer(itemnum));
out.println("Your cart is:"+cart.entrySet());
%>
<HR>
<table border="1" bordercolor="red">
<%
String str="";
out.println("your select:");
str+="<tr><td>"+cart.entrySet()+"</td></tr>";
out.println(str);
%>
Thank you!
Thank you tolmank.It's works well.This is mycode after modify.But I find it also works well if I delete the last sentence "session.setAttribute("lyo",cart);".It must be writen?
/////////////////////////mycode after modify//////////////////////////////////////
String item="";
String itemnum;
String submit;
int itemn;
int oldcartnum;
item=request.getParameter("item");
itemnum=request.getParameter("itemnumber");
submit=request.getParameter("Submit");
try{
itemn=(Integer.valueOf(itemnum)).intValue();
}catch(NumberFormatException e){
itemn=1;
out.println("Your select is:"+item);
out.println("Item number is:"+itemnum);
HashMap cart;
if(session.isNew()){
cart=new HashMap();
session.setAttribute("lyo",cart);
}else if((session.getAttribute("lyo"))==null){
cart=new HashMap();
session.setAttribute("lyo",cart);
}else{
cart=(HashMap)session.getAttribute("lyo");
if(submit.equals("Add")){
try{
oldcartnum=((Integer)(cart.get(item))).intValue();
}catch(NullPointerException ex){
oldcartnum=0;
cart.put(item,new Integer(oldcartnum+itemn));
//session.setAttribute("lyo",cart);
out.println("Your cart is:"+cart.entrySet());
%>
<HR>
<table border="1" bordercolor="red">
<%
String str="";
out.println("your select:");
str+="<tr><td>"+cart.entrySet()+"</td></tr>";
out.println(str); }
Similar Messages
-
Urjent-how to add line items in tcode-FBL3N
Hi Experts,
How to add line items customer, customer name, vendor and vendor name in FBL3N.
Thanks in advance.
mahe
Moderator message - Please do not use words like "urjent". Please ask a specific question. Please search the forum. This question has been asked and answered before. Post locked
Edited by: Rob Burbank on Apr 29, 2009 11:27 AM
Edited by: Rob Burbank on Apr 29, 2009 11:28 AMHi,
Check the BTE's:
00001020 POST DOCUMENT: Prior to final checks SAMPLE_INTERFACE_00001020
00001025 POST DOCUMENT: Final checks completed SAMPLE_INTERFACE_00001025
00001030 POST DOCUMENT: Posting of standard data SAMPLE_INTERFACE_00001030
00001050 POST DOCUMENT: Accounting interface SAMPLE_INTERFACE_00001050
Thanks & Regards,
Harish -
How to add Excise item with out chapter id
Dear all,
How to add Excise item with out chapter id?
Chapter id of purchae items will be known only after receiving Invoice/gate pass/delivery chalan from supplier/vendor
To send a purchase order we need to create that particular item in the master, but with out assigning chapter id system is not allowing to save without chapter id.
How to solve this?
I am with SAP 8.8 and PL 10
Thanks in advance
regards,
KumarHi Kumar,
Refer the book of chapter ID or find out on internet you will get the chapter ID.
Still if you not able to get the chapter id then consult with excise advisory.
But you can add Excise PO until you have the excise details in Item master.
Regards,
Datta Kharat -
How to add an item into the Newsstand
How to add an item into the Newsstand. Please do NOT reply using "tech-language." Use standard- normal everyday English. Thanks,
Don Otlin
Franklin Square, NYOpen Newsstand. Tap on the "Store" button in the upper right. Any newspaper or magazine you download from the store will appear in Newsstand.
-
How to add new item in more options dialog box
Hi all,
Can anyone tell me how to add new item in more options dialog box(site actions -> more options). I want to add new item there to the new page layout which I created but I didn't find any way to do it. can anyone assist me for this.Good point, in order to add a Page into that area, you will need to define a Custom Action. You can learn more about creating Custom Actions here:
http://msdn.microsoft.com/en-us/library/hh500259(v=office.14).aspx
As an example, Microsoft uses the following Custom Action to add the "Publishing Page" to that Create Silverlight control when enabling the Publishing features:
<CustomAction
Id="CreatePublishingPage"
GroupId="WebPages"
Location="Microsoft.SharePoint.Create"
Sequence="100"
Title="$Resources:cmscore,Create_WebPages_PublishedPage;"
Description="$Resources:cmscore,Create_WebPages_PublishedPage_Description;"
ImageUrl="/_layouts/images/ltpp.png">
<UrlAction Url="_Layouts/CreatePage.aspx" />
</CustomAction>
Dimitri Ayrapetov (MCSE: SharePoint) -
Need detailed procedure on how to add an item with Item Style Check Box in
Need detailed procedure on how to add an item with Item Style Check Box in Framework.
The view instance should be the same as the view instance (view object) specified for your region.
If the View Attribute already that you need already exists in the View Object then you can use it.
Otherwise you have to extend the View Object and add the new attribute to it.
--Prasanna -
How to add a item to shopping cart in iProcurement by java codes.
I have encountered a problem in the development of iProcurement, I don't know how to add a item into the shopping cart. Please help me.
This is the Configurator forum, your question is probably better posed in the Procurement forum (Procurement
-
How to add Service item in PR Document using BAPI_PR_CHANGE
Hi Folks,
I am using BAPI_PR_CHANGE to change existing purchase requisition document. By using this FM, i am able to add new item in PR document.
Now my requirement is to add services and limits at item level details.
But when i saw the parameter list of this FM, i am not able to find any parameter where service details or limits can be passed.
So does it mean that, its not possible to edit service details at item level of PR by using FM BAPI_PR_CHANGE?
Or if yes then how can we do it.
If No, then what could be the alternative to change the service details of the item.
Regards
PG
Edited by: PG on Aug 30, 2010 6:32 PMHi,
I just realised that, this question can be asked in specific forum of MM.
Regards
PG -
How to add an item in the combobox list at runtime
i want to add an item to the list of items in the combobox. How can I do this? I tried to use the methods getselecteditem() and getitem() from the actionlistener but no success.
so after i add an item, the next time when i run that frame, that item should be displayed in the list of items in the combobox. Can anybody help me with this?Thanks Encephalophathic.
Let me explain you the whole design -
I have a frame having textfields and comboboxes. Now in the combobox, i have added some fields during design time and some i want the user to add at runtime. After the user clicks the Save button, i want the new string if entered in the combobox by the user at runtime to be added in the list of items of the combobox. So the next time when that frame is run, the item added by the user at runtime previously should be there in the list of items displayed in the combobox.
What I am trying to do in this code at the combobox is if the user enters a new string in the combobox, then if he presses enter key, the value entered in the list of the combobox should be entered in the list of items of the combobox. Actually i m just trying to get the item typed in by the user, so just testing with enter key, but really i want it on the button click. I tried to add the code for adding an item to the combobox in the actionperformed, but i m not able to add it so confused what to do. Please help me with this.
Here's the whole code for that -
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JDialog.*;
import javax.swing.JComboBox;
public class EnterFD implements ActionListener{
private JFrame frame;
private JPanel mainpanel,menupanel,userinputpanel,buttonpanel;
private JMenuBar menubar;
private JMenu menu,submenu;
private JMenuItem menuitem;
private JCheckBoxMenuItem cbmenuitem;
private JLabel fdnumber;
private JLabel bankname;
private JLabel beneficiaryname;
private JLabel entereddate;
private JLabel maturitydate;
private JLabel rateofinterest;
private JLabel amount;
private JLabel maturityamount;
private JTextField fdnumbertxtfield;
private JComboBox banknamecombobox;
private JTextField beneficiarynametxtfield;
private JComboBox entereddatecombobox;
private JComboBox maturitydatecombobox;
private JTextField rateofinteresttxtfield;
private JTextField amounttxtfield;
private JTextField maturityamounttxtfield;
private JButton savebutton;
private JButton clearbutton;
public EnterFD() {
initComponents();}
private final void initComponents(){
fdnumber = new JLabel("FD Number:");
bankname = new JLabel("Bank Name:");
beneficiaryname = new JLabel("Beneficiary Name:");
entereddate = new JLabel("Entered Date:");
maturitydate = new JLabel("Maturity Date:");
rateofinterest = new JLabel("Rate Of Interest:");
amount = new JLabel("Amount:");
maturityamount = new JLabel("Maturity Amount:");
fdnumbertxtfield = new JTextField();
banknamecombobox = new JComboBox();
banknamecombobox.addItem("State Bank Of India");
banknamecombobox.addItem("Bank Of Baroda");
banknamecombobox.addItem("IDBI Bank");
banknamecombobox.addItem("ICICI Bank");
banknamecombobox.addItem("Punjab National Bank");
banknamecombobox.setEditable(true);
banknamecombobox.setSelectedIndex(-1);
banknamecombobox.addKeyListener(new java.awt.event.KeyAdapter() {
@Override
public void keyTyped(java.awt.event.KeyEvent evt) {
banknamecomboboxKeyTyped(evt);
banknamecombobox.addKeyListener(new java.awt.event.KeyAdapter() {
@Override
public void keyReleased(java.awt.event.KeyEvent evt) {
banknamecomboboxKeyReleased(evt);
beneficiarynametxtfield = new JTextField();
entereddatecombobox = new JComboBox();
maturitydatecombobox = new JComboBox();
rateofinteresttxtfield = new JTextField();
amounttxtfield = new JTextField();
maturityamounttxtfield = new JTextField();
menubar = new JMenuBar();
menu = new JMenu("File");
menubar.add(menu);
menuitem = new JMenuItem("New");
menu.add(menuitem);
menuitem.addActionListener(this);
menuitem = new JMenuItem("Save");
menu.add(menuitem);
menuitem.addActionListener(this);
menuitem = new JMenuItem("Close");
menu.add(menuitem);
menuitem.addActionListener(this);
menuitem = new JMenuItem("Exit");
menu.add(menuitem);
menuitem.addActionListener(this);
menu = new JMenu("Edit");
menubar.add(menu);
menuitem = new JMenuItem("View FD");
menu.add(menuitem);
menuitem.addActionListener(this);
mainpanel = new JPanel(new BorderLayout());
menupanel = new JPanel(new BorderLayout());
menupanel.add(menubar);
userinputpanel = new JPanel(new GridLayout(8,2,5,20));
userinputpanel.setBorder(BorderFactory.createEmptyBorder(50,50,80,80));
userinputpanel.add(fdnumber);
userinputpanel.add(fdnumbertxtfield);
fdnumbertxtfield.setColumns(50);
userinputpanel.add(bankname);
userinputpanel.add(banknamecombobox);
userinputpanel.add(beneficiaryname);
userinputpanel.add(beneficiarynametxtfield);
beneficiarynametxtfield.setColumns(50);
userinputpanel.add(rateofinterest);
userinputpanel.add(rateofinteresttxtfield);
rateofinteresttxtfield.setColumns(50);
userinputpanel.add(amount);
userinputpanel.add(amounttxtfield);
amounttxtfield.setColumns(50);
userinputpanel.add(maturityamount);
userinputpanel.add(maturityamounttxtfield);
maturityamounttxtfield.setColumns(50);
savebutton = new JButton("Save");
clearbutton = new JButton("Clear");
JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonpanel.add(savebutton);
buttonpanel.add(clearbutton);
savebutton.addActionListener(this);
clearbutton.addActionListener(this);
mainpanel.add(menupanel,BorderLayout.NORTH);
mainpanel.add(userinputpanel,BorderLayout.CENTER);
mainpanel.add(buttonpanel,BorderLayout.SOUTH);
frame = new JFrame("Enter FD");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(3000,3000);
frame.setContentPane(mainpanel);
frame.pack();
frame.setVisible(true); } -
How to add an Item to as Displayable
The documentation for the Display class says that the setCurrentItem method "requests that the Displayable that contains this Item be made current". How can I add an Item to a Displayable? Only the Form class has an append(Item item) method.
In fact I want to use a TextfFeld in a GameCanvas. Maybe you could suggest me another way to do this.
Thank You!Hi,
It's not possible to 'append' a StringItem or a TextField (or any other lcdui.Item object) to a Canvas or GameCanvas. You can only draw lines, draw images, draw text, etc etc, on a Canvas screen. So, you can only 'simulate' the look and feel of a TextField (on a Canvas) by painting it and adding source code for command handling (like key presses). However, this will be quite some work!!
lcdui.Item objects can only be 'appended' to a Form-like Displayable.
Cheers for now,
Jasper -
How can add multiple item in form .
hi,
i have a critical problem .i am creating a check in form for hotel .Now problem is when i fill personal details of Customer with his three family member .here i want to enter all three member name and there relationship with customer .so how can i insert three text fild for name and relation ship in middle of form .Member may be three or Five .
how can i add multiple item in middle of form according to required .
Thanks
ManojI'm assuming that you're talking about an Application Express Form here. In that case, have you thought about using a "master-detail" form? Take a look at the example here Adding a Master Detail Form.
C. -
How to add an item object as a child for a specified parent node in AdvancedDataGrid in Flex?
Hi all,
This is the code, to add a object as a child into a specified parent node in AdvancedDataGrid in flex.
<?xml version="1.0" encoding="utf-8"?><mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()" width="100%" height="100%">
<mx:Script><![CDATA[
importmx.controls.Alert;
importmx.collections.IHierarchicalCollectionViewCursor;
importmx.collections.IHierarchicalCollectionView;
importmx.collections.ArrayCollection; [
Bindable]private var objectAC:ArrayCollection = newArrayCollection();
//This method is used to construct the ArrayCollection 'flatData'
private function onCreationComplete():void{
var objOne:Object = newObject(); objOne.name =
"Rani"; objOne.city =
"Chennai";objectAC.addItem(objOne);
var objTwo:Object = newObject(); objTwo.name =
"Rani"objTwo.city =
"Bangalore";objectAC.addItem(objTwo);
var objThree:Object = newObject(); objThree.name =
"Raja"; objThree.city =
"Mumbai";objectAC.addItem(objThree);
//This method is used to add one object as a child item for the parent node 'Rani'
private function addChildItem():void{
var dp:IHierarchicalCollectionView = groupedADG.dataProvider asIHierarchicalCollectionView;
varcurent:IHierarchicalCollectionViewCursor = groupedADG.dataProvider.createCursor();
var dummyParentNode:Object = {name:"Rani", city:"New Delhi"};
var obj:Object = null;
while(curent.current){
// To get the current node objectobj = curent.current;
// Add Child item, when depth = 1 and Node name should be "Rani"
if (curent.currentDepth == 1 && obj["GroupLabel"] == "Rani"){
dp.addChild(curent.current, dummyParentNode);
curent.moveNext();
groupedADG.dataProvider = dp;
groupedADG.validateNow();
groupedADG.dataProvider.refresh();
]]>
</mx:Script>
<mx:AdvancedDataGrid id="groupedADG" x="10" y="15" designViewDataType="tree" defaultLeafIcon="{null}" sortExpertMode="true" width="305" >
<mx:dataProvider>
<mx:GroupingCollection id="gc" source="{objectAC}">
<mx:grouping>
<mx:Grouping>
<mx:GroupingField name="name"/>
</mx:Grouping>
</mx:grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Name" dataField="name"/>
<mx:AdvancedDataGridColumn headerText="City" dataField="city"/>
</mx:columns>
</mx:AdvancedDataGrid>
<mx:Button x="10" y="179" label="Open the folder 'Rani'. Then Click this Button" width="305" click="addChildItem()" />
</mx:Application>Hi,
It's not possible to 'append' a StringItem or a TextField (or any other lcdui.Item object) to a Canvas or GameCanvas. You can only draw lines, draw images, draw text, etc etc, on a Canvas screen. So, you can only 'simulate' the look and feel of a TextField (on a Canvas) by painting it and adding source code for command handling (like key presses). However, this will be quite some work!!
lcdui.Item objects can only be 'appended' to a Form-like Displayable.
Cheers for now,
Jasper -
How to add one item when another item get added into the iProcurement Cart
Hi,
Please help me to do the following customization in iProcurement Cart:
Requirement-1:
1. Login to iProcurement and add one Item ITEM1 to Cart.
2. Make another Item ITEM2 mandatory or get added automatically when Item ITEM1 gets added into the iProcurement Cart
OR
Requirement-2:
1. Login to iProcurement and add one Item ITEM1 to Cart.
2. Go to Cart and click Checkout.
3. While checking out Item ITEM1, we need some validation to make another Item ITEM2 mandatory or get added automatically with Item ITEM1.
Thanks in Advance,
SBHi tiff512:
The way is:
SAP NetWeaver > General Settings > Check Units of Measurement.
The help documentation says the following in relation to the creation of new units of measure:
"If required, define new units of measurement according to the international system of units (SI) with the menu function Unit of meaurement -> Create.
Here you have to make make specifications for:
Display (including a descriptive Units of measurement text)
Conversion (not applicable to units of measurement without dimensions)
Data exchange (EDI) (optional)
Application parameters"
I hope it is helpful to you.
Regards,
David -
How to add line item to sales order item table?
Kindly help me the with the below requirement .
Add line item to sales order(va01) dynamically on click of button. The button is also custom created push button.
In the above requirement I have added the pushbutton to va01 tcode. But when I click on that button I need to add line item to sales order item table.
I tried a lot but I am not successful. If possible can u please help on this.
Regards,
RachelHi!
It's quite easy even in the standard SAP to add a line item for a customer order, I don't think it worth to develop a new button for this.
However if you wanted to add a line automatically, the you can do the following in the program MV45AFZZ, FORM USEREXIT_SAVE_DOCUMENT.
You can use similar code, but with some modifications.
DATA: lv_posnr.
LOOP AT xvbap.
MOVE xvbap-posnr TO lv_posnr. "get the last posnr
ENDLOOP.
ADD 10 TO lv_posnr.
MOVE 'XYZ' TO xvbap-matnr. "enter your material number here
MOVE lv_posnr TO xvbap-posnr.
* fill additinal field data in XVBAP if necessary
MOVE 'I' TO xvbap-updkz. "Insert line
APPEND xvbap.
Regards
Tamá -
How to add menu item in Virtual Folders Actions Menu
Hi ,
I am writting a custom component which will add some action on documents and virtual folder.
I am able to add the menu item for DocInfo, but not able to add Menu Item in Virtual Folders Actions Menu.
Please help!!
thanksI am able to add the menu item for DocInfo, but not able to add Menu Item in Virtual Folders Actions Menu.What exactly you are trying to modify? If web GUI, it should be following the same principles as your "DocInfo" changes (only the basis service is COLLECTION_DISPLAY). If you are trying to modify Desktop Integration Suite, I'm afraid there is no help (at least, I have not heard that DIS could be modified by custom components).
Maybe you are looking for
-
Can't install the software for the EPSON Epson Stylus Photo R2000 because it is not currently available from the Software Update server??? I am using mac osx 10.8 and now cant get print software for epson R2000 printer.
-
In safari I was not able to wish my frnds on their bdays in event section of facebook right top corner.. Is there any way to fix this..
-
My iMac has OS X 10.9, graphic card ATI Radeon HD 2600 Pro 256 Mo. Where could I find "the minimum system requirements" for iMovie. Thanks
-
Final Cut License/Reinstall
Does anyone know if upon removing and reinstalling FCP, after a hard drive reformat, if you have to deactivate the license before reinstalling. I have reformatted my hard drive and reinstalled my FCP, but for some reason my license is showing invalid
-
10.6.3 download itunes
i want to update itunes with version 10.6.3 for window 7 ..... free but i don't know how