Hi Pieter,

Thanks for the reply

and to take that particular entity i need a key a primary key which i
have made but how to use and get that key
and i m using servlet for handling my submissions

Here is the code for that


package com.purchase.sample.client;

import java.io.IOException;
import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class purchase extends HttpServlet
{
    public void doPost(HttpServletRequest req, HttpServletResponse
resp) throws IOException
    {

        String itemname = req.getParameter("itemname");
        int itemqty = Integer.parseInt(req.getParameter("itemqty"));
        int unitprice =
Integer.parseInt(req.getParameter("unitprice"));
        int totprice = itemqty * unitprice;
        String comments = req.getParameter("comments");
        String mgrcomments = req.getParameter("mgrcomments");
        String itcomments = req.getParameter("itcomments");
        java.text.DateFormat timedate
=java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL);
        String timedate1 = timedate.format( new java.util.Date() );
        PurchaseInfo pinfo = new PurchaseInfo(itemname, itemqty,
unitprice, totprice, comments, mgrcomments, itcomments, timedate1);
        PersistenceManager pm = PMF.get().getPersistenceManager();

        try
        {
            pm.makePersistent(pinfo);
        }
        finally
        {
            pm.close();
        }

        resp.sendRedirect("/UserType.jsp");
    }
}

and this the code of JSP file from which it will get values

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.jdo.JDOHelper" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="javax.jdo.PersistenceManagerFactory" %>
<%@ page import="com.purchase.sample.client.PurchaseInfo" %>
<%@ page import="com.purchase.sample.client.PMF" %>
<%@ page import="com.google.gwt.i18n.client.DateTimeFormat"%>
<%@ page import= "java.util.Date"%>

<html>
<head>
    <link type="text/css" rel="stylesheet" href="/stylesheets/
main.css" />

<script type="text/javascript">

funtion funedit()
{
<%
        PersistenceManager pm1 = PMF.get().getPersistenceManager();
        String query1 = "select item from " + PurchaseInfo.class.getName() +
"where key = 12";
        List<PurchaseInfo> purchase1 = (List<PurchaseInfo>)
pm1.newQuery(query1).execute();
         for (PurchaseInfo p1 : purchase1)
         {
%>
                document.getElementById("itemname").value = <!--%=p1.getitem()%>
<%
         }
%>
}

</script>


</head>

<body class="body">

<div class="marginleft">
        <a href="UserType.jsp" style="font-size: medium;font-weight: 20;text-
decoration: none;">HOME </a>|
        <span style="font-size: medium;font-weight: 20;">Welcome, Employee      
</
span>
</div>


<%
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "select from " + PurchaseInfo.class.getName();
    List<PurchaseInfo> purchase = (List<PurchaseInfo>)
pm.newQuery(query).execute();
    if (purchase.isEmpty())
    {
%>

<p>There are no requests</p>

<%
    }
    else
    {
        for (PurchaseInfo p : purchase)
        {
%>

<table border="1" width="600">
        <caption align="left"><b>Request Made</b></caption>
<tr>
<th> Key Value</th>
<th> Item Name</th>
<th> Item Quantity</th>
<th> Item UnitPrice</th>
<th> Item TotalPrice</th>
<th> Employee Remarks</th>
<th> Press to Edit </th>
<!-- th> Employee date</th-->
</tr>

<tr>
                <td>
                        <blockquote><%= p.getkey()%></blockquote>
                </td>
                <td>
                        <blockquote><%= p.getitem()%></blockquote>
                </td>
                <td>
                        <blockquote><%= p.getqty()%></blockquote>
                </td>
                <td>
                        <blockquote><%= p.getunit_price()%></blockquote>
                </td>
                <td>
                        <blockquote><%= p.gettotal_price()%></blockquote>
                </td>
                <td>
                        <%= p.getcomments()%>
                </td>
                <td >
                        <blockquote><input type="button" value="Edit" 
id="editbtn"
onclick="javascript:funedit();">
                        </blockquote>
                </td>
                <!--td>
                        <blockquote><!--%= p.getdatetime()%></blockquote>
                </td-->
</tr>
</table>

<br/>

<%
        }
    }
    pm.close();
%>

    <form action="/purchase1/sign" method="post" name="gui">
    <table>
    <tr>
      <td>Enter Item Name</td>
      <td><div><input type="text" name="itemname"></div></td>
    </tr>
    <tr>
      <td>Enter Item Quantity</td>
      <td><div><input type="text" name="itemqty"></div></td>
    </tr>
    <tr>
      <td>Enter Unit Price</td>
      <td><div><input type="text" name="unitprice"></div></td>
    </tr>
    <tr>
      <td>Employee Remarks</td>
      <td>
        <div><input type="text" name="comments"></div>
      </td>
    </tr>
    <tr>
    <td>    </td>
    <td>
        <div class="Button" align="center"><input type="submit" id="add"
value="ADD" width="25" height="10"/>
        </div>
    </td>
    </tr>

    </table>
    </form>

<div class="marginleft">
        <a href="UserType.jsp" style="font-size: medium;font-weight: 20;"
>HOME</a>
</div>

  </body>
</html>

PLease see the code and suggest me the edit and also update
functionality how to implement


Thank You So Much






On Aug 12, 12:02 pm, Pieter Coucke <[email protected]> wrote:
> If you want to edit an entity, you just need to get it from the datastore,
> set some properties on it and the PersistenceManager will save this changes
> when you call pm.close().
>
> You might consider using a framework like Spring for handling form
> submissions.  You can also use a normal Servlet, but this can become
> difficult to maintain.
>
> On Thu, Aug 12, 2010 at 7:20 AM, prakhil samar <[email protected]>wrote:
>
>
>
>
>
>
>
> > Hi Ikai,
>
> > I m waiting for your reply is there anything that i didnt explained
> > correctly, please do tell me
>
> > Thanks
>
> > On Aug 11, 9:26 am, prakhil samar <[email protected]> wrote:
> > > Thanks Ikai,
>
> > > I had already read some of the docs from google code about java and
> > > data stores
> > > I had stored and retrived my data through data store but want a edit
> > > and update functionality in my application for that i have to use a
> > > primary key
>
> > >  Written this code --
> > >     @PrimaryKey
> > >     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > >      private Key key;
>
> > > I made a java page in which i m writing all my setter and getter
> > > methods and this key
> > > Then, I made a jsp page and in that made a form for a user to enter
> > > the data and as he press submit it will display on the same page his
> > > data entered in a table.
> > > Now i want to edit the data and show it in the form so that user can
> > > edit and then update the data
>
> > > I have made this sample application, please visit this link
>
> > >                    http://pur10app.appspot.com/
>
> > > Here in Employee Form i want the edit and update functionality
>
> > > Please help me out
>
> > > Thanks, in advance
>
> > > On Aug 10, 10:38 pm, "Ikai L (Google)" <[email protected]> wrote:
>
> > > > You'll want to read the docs and do the tutorials that are available.
> > Many
> > > > new developers find that a self-guided approach is the most effective
> > for
> > > > learning a new skill.
>
> > > >http://code.google.com/appengine/docs/java/gettingstarted/https://sit.
> > ..
>
> > > > On Mon, Aug 9, 2010 at 9:15 PM, prakhil samar <[email protected]
> > >wrote:
>
> > > > > Hi all
> > > > > I m new to  Google App Engine and JAVA i m building an applciation in
> > > > > which data is to be saved and retrieved as and when required (Add,
> > > > > Edit, Update functionality is must). please someone tell me how to do
> > > > > that, i m using Eclipse IDE and java language, I have Added the data
> > > > > in data store but how to edit and then update that data PLease help
> > > > > me, its urgent..........
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > > "Google App Engine" group.
> > > > > To post to this group, send email to
> > [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<google-appengine%[email protected]>
> > <google-appengine%2bunsubscrib­[email protected]>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-appengine?hl=en.
>
> > > > --
> > > > Ikai Lan
> > > > Developer Programs Engineer, Google App Engine
> > > > Blog:http://googleappengine.blogspot.com
> > > > Twitter:http://twitter.com/app_engine
> > > > Reddit:http://www.reddit.com/r/appengine-Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-appengine%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> Pieter Coucke - Onthoo BVBA <http://www.onthoo.com/>
> zamtam.com <http://www.zamtam.com> in The
> Netherlands<http://www.koopjeszoeker.com/>| Belgium (
> nl <http://www.koopjeszoeker.be/> | fr <http://fr.zamtam.be/>) |
> France<http://www.zamtam.fr/>|
> Germany <http://www.zamtam.de/> | UK
> <http://www.zamtam.co.uk/><http://www.zamtam.co.uk/>- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to