⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendarlistpagegenerator.java

📁 Rapla是一个灵活的多用户资源管理系统。它提供的一些功能有:日历GUI
💻 JAVA
字号:
/*--------------------------------------------------------------------------*
 | Copyright (C) 2006 Christopher Kohlhaas                                  |
 |                                                                          |
 | This program is free software; you can redistribute it and/or modify     |
 | it under the terms of the GNU General Public License as published by the |
 | Free Software Foundation. A copy of the license has been included with   |
 | these distribution in the COPYING file, if not go to www.fsf.org         |
 |                                                                          |
 | As a special exception, you are granted the permissions to link this     |
 | program with every library, which license fulfills the Open Source       |
 | Definition as published by the Open Source Initiative (OSI).             |
 *--------------------------------------------------------------------------*/
package org.rapla.plugin.autoexport;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.rapla.components.util.IOUtil;
import org.rapla.entities.User;
import org.rapla.entities.configuration.CalendarModelConfiguration;
import org.rapla.entities.configuration.Preferences;
import org.rapla.entities.configuration.RaplaMap;
import org.rapla.facade.RaplaComponent;
import org.rapla.framework.RaplaContext;
import org.rapla.framework.RaplaException;
import org.rapla.servletpages.RaplaPageGenerator;

/******* USAGE: ************
 * ReadOnly calendarview view.
 * You will need the autoexport plugin to create a calendarview-view.
 *
 * Call:
 * rapla?page=calendar&user=<username>&file=<export_name>
 *
 * Optional Parameters:
 *
 * &hide_nav: will hide the navigation bar.
 * &day=<day>:  int-value of the day of month that should be displayed
 * &month=<month>:  int-value of the month
 * &year=<year>:  int-value of the year
 * &today:  will set the view to the current day. Ignores day, month and year
 * @throws IOException
 * @throws ServletException
 * @throws Exception
 * @throws RaplaException
 */
public class CalendarListPageGenerator extends RaplaComponent implements RaplaPageGenerator
{
    public CalendarListPageGenerator( RaplaContext context ) throws RaplaException
    {
        super( context );
    }

    public void generatePage( ServletContext servletContext, HttpServletRequest request, HttpServletResponse response )
            throws IOException, ServletException
    {
        try
        {
            String username = request.getParameter( "user" );
            java.io.PrintWriter out = response.getWriter();
    
            User[] users = getQuery().getUsers();
            if ( username != null)
            {
                users = new User[] { getQuery().getUser( username )}; 
            }
            
            for ( int i=0;i<users.length;i++)
            {
                User user = users[i];
                out.println( "<h2>User " + user.getName() + " [" + user.getUsername() + "]</h2>" );            

                Preferences preferences = getQuery().getPreferences( user );
                if ( preferences.hasEntry( "org.rapla.plugin.autoexport" ) )
                {
                    Iterator it  = ( (RaplaMap) preferences.getEntry( "org.rapla.plugin.autoexport" ) ).entrySet().iterator();
                    out.println( "<ul>" );
                    while ( it.hasNext())
                    {
                        Map.Entry entry = (Map.Entry)it.next();
                        String key = (String) entry.getKey();
                        CalendarModelConfiguration conf  = (CalendarModelConfiguration)entry.getValue();
                        String title = conf.getTitle() ;
                        if ( title == null || title.trim().length() == 0)
                        {
                            title = key;
                        }
                        String filename =URLEncoder.encode( key, "UTF-8" );

                        out.print( "<li>" );
                        out.print( "<a href=\"?page=calendar&user=" + user.getUsername() + "&file=" + filename + "\">");
                        out.print( title);
                        out.print( "</a>" );
                        out.println( "</li>" );
                    }
                    out.println( "</ul>" );
                    
                }
            }
        }
        catch ( Exception ex )
        {
            java.io.PrintWriter out = response.getWriter();
            out.println( IOUtil.getStackTraceAsString( ex ) );
            throw new ServletException( ex );
        }
    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -