Package org.apache.jetspeed.tutorial.om

Examples of org.apache.jetspeed.tutorial.om.Cafe


    protected void buildNormalContext(VelocityPortlet portlet,
                                       Context context,
                                       RunData rundata)
    {
        String mode = null;
        Cafe cafe = null;

        try
        {
            mode = this.getQueryParameter(rundata, UI_MODE, UI_REFRESH);
            cafe = (Cafe)rundata.getUser().getTemp(SESSION_CAFE);

            // refresh mode - simply keep state of fields from session,
            // the request is for another portlet or simply a refresh
            //
            if (mode.equalsIgnoreCase(UI_REFRESH))
            {
                if (cafe != null)
                {
                    rundata.getParameters().setProperties(cafe);
                }               
            }
            else if (mode.equalsIgnoreCase(UI_EDIT) ||
                     mode.equalsIgnoreCase(UI_DELETE))
            {
                int rowid = Integer.parseInt(this.getQueryParameter(rundata, UI_ROW_ID));

                context.put(UI_ROW_ID, String.valueOf(rowid));

                // get the primary key and put the object in the context
                Criteria criteria = new Criteria();
                criteria.add( CafePeer.CAFE_ID, rowid);
                List cafes = CafePeer.doSelect(criteria);
                if (cafes != null && cafes.size() > 0)
                {
                    cafe = (Cafe)cafes.get(0);
                }
                else
                {
                    throw new Exception("Cafe for id="+rowid+" not found.");
                }

                rundata.getUser().setTemp(SESSION_CAFE, cafe);

                rundata.getUser().setTemp(SESSION_UPDATE_MODE, mode);

            }
            else if (mode.equalsIgnoreCase(UI_ADD))
            {
                cafe = new Cafe();
                cafe.setCafeName("");
                rundata.getUser().setTemp(SESSION_CAFE, cafe);
                rundata.getUser().setTemp(SESSION_UPDATE_MODE, mode);
            }

            context.put(UI_CAFE, cafe);
View Full Code Here


     * @param rundata The turbine rundata context for this request.
     * @param context The velocity context for this request.
     */
    public void doUpdate(RunData rundata, Context context) throws Exception
    {
        Cafe cafe = null;
        Connection con = null;

        try
        {
            con = Torque.getConnection();

            cafe = (Cafe)rundata.getUser().getTemp(SESSION_CAFE);

            if(cafe == null)
            {
                Log.error(NO_CURRENT_REC);
                rundata.setMessage(NO_CURRENT_REC);
                return;
            }
       
            rundata.getParameters().setProperties(cafe);

            validate(cafe);

            cafe.save(con);

            con.commit();

            returnToBrowser(rundata, true);
           
View Full Code Here

     * @param rundata The turbine rundata context for this request.
     * @param context The velocity context for this request.
     */
    public void doDelete(RunData rundata, Context context) throws Exception
    {
        Cafe cafe = null;
        Connection con = null;

        try
        {
            con = Torque.getConnection();
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.tutorial.om.Cafe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.