Example usage for com.liferay.portal.kernel.servlet SessionMessages add

List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet SessionMessages add.

Prototype

public static void add(PortletRequest portletRequest, String key) 

Source Link

Usage

From source file:org.liferay.jukebox.portlet.ArtistsPortlet.java

License:Open Source License

public void deleteArtist(ActionRequest request, ActionResponse response) throws Exception {

    long artistId = ParamUtil.getLong(request, "artistId");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(Artist.class.getName(), request);

    try {//from   ww w  .j a va2  s . com
        ArtistServiceUtil.deleteArtist(artistId, serviceContext);

        SessionMessages.add(request, "artistDeleted");

        sendRedirect(request, response);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());

        response.setRenderParameter("jspPage", "/html/error.jsp");
    }
}

From source file:org.liferay.jukebox.portlet.ArtistsPortlet.java

License:Open Source License

public void updateArtist(ActionRequest request, ActionResponse response) throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);

    long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
    String name = ParamUtil.getString(uploadPortletRequest, "name");
    String bio = ParamUtil.getString(uploadPortletRequest, "bio");

    InputStream inputStream = uploadPortletRequest.getFileAsStream("file");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(Artist.class.getName(),
            uploadPortletRequest);/* w ww  .ja  va2  s.c om*/

    try {
        ArtistServiceUtil.updateArtist(artistId, name, bio, inputStream, serviceContext);

        SessionMessages.add(request, "artistUpdated");

        String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");

        response.sendRedirect(redirect);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());

        if (e instanceof ArtistNameException || e instanceof PrincipalException) {

            response.setRenderParameter("jspPage", "/html/artists/edit_artist.jsp");
        } else {
            response.setRenderParameter("jspPage", "/html/error.jsp");
        }
    }
}

From source file:org.liferay.jukebox.portlet.JukeboxPortlet.java

License:Open Source License

public void addSong(ActionRequest request, ActionResponse response) throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);

    long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
    String name = ParamUtil.getString(uploadPortletRequest, "name");

    InputStream songInputStream = uploadPortletRequest.getFileAsStream("songFile");
    String songFileName = uploadPortletRequest.getFileName("songFile");

    InputStream lyricsInputStream = uploadPortletRequest.getFileAsStream("lyricsFile");
    String lyricsFileName = uploadPortletRequest.getFileName("lyricsFile");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(Song.class.getName(),
            uploadPortletRequest);/*  www  .  jav  a2  s  .co m*/

    try {
        SongServiceUtil.addSong(albumId, name, songFileName, songInputStream, lyricsFileName, lyricsInputStream,
                serviceContext);

        SessionMessages.add(request, "songAdded");

        String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");

        response.sendRedirect(redirect);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());

        if (e instanceof SongNameException || e instanceof DuplicatedSongException
                || e instanceof PrincipalException) {

            response.setRenderParameter("jspPage", "/html/songs/edit_song.jsp");
        } else {
            response.setRenderParameter("jspPage", "/html/error.jsp");
        }
    }
}

From source file:org.liferay.jukebox.portlet.JukeboxPortlet.java

License:Open Source License

public void updateSong(ActionRequest request, ActionResponse response) throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(request);

    long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
    long songId = ParamUtil.getLong(uploadPortletRequest, "songId");
    String name = ParamUtil.getString(uploadPortletRequest, "name");

    InputStream songInputStream = uploadPortletRequest.getFileAsStream("songFile");
    String songFileName = uploadPortletRequest.getFileName("songFile");

    InputStream lyricsInputStream = uploadPortletRequest.getFileAsStream("lyricsFile");
    String lyricsFileName = uploadPortletRequest.getFileName("lyricsFile");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(Song.class.getName(),
            uploadPortletRequest);/*from  w  w w. j  a va  2s .  co  m*/

    try {
        SongServiceUtil.updateSong(songId, albumId, name, songFileName, songInputStream, lyricsFileName,
                lyricsInputStream, serviceContext);

        SessionMessages.add(request, "songUpdated");

        String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");

        response.sendRedirect(redirect);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());

        if (e instanceof SongNameException || e instanceof PrincipalException) {

            response.setRenderParameter("jspPage", "/html/songs/edit_song.jsp");
        } else {
            response.setRenderParameter("jspPage", "/html/error.jsp");
        }
    }
}

From source file:org.oep.cmon.admin.portlet.action.AdminActionPortlet.java

License:Apache License

/**
 * This is  function add role for Agency Manager
 * Version: 1.0/*from   w w  w. j a va2 s  . c o  m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void addQuyenToCoQuanQuanLy(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    new CoQuanQuanLyAction().addQuyenToCoQuanQuanLy(actionRequest, actionResponse);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.admin.portlet.action.AdminActionPortlet.java

License:Apache License

/**
 * This is  function load role Agency Manager
 * Version: 1.0//  ww  w . ja v  a 2s.co  m
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void reloadQuyenToCoQuanQuanLy(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    new CoQuanQuanLyAction().reloadQuyenToCoQuanQuanLy(actionRequest, actionResponse);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.admin.portlet.action.AdminActionPortlet.java

License:Apache License

/**
 * This is  function delete role Agency Manager
 * Version: 1.0/*from  www . j a  v  a  2  s  .  c  o m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void deleteQuyenToCoQuanQuanLy(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    new CoQuanQuanLyAction().deleteQuyenToCoQuanQuanLy(actionRequest, actionResponse);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.admin.portlet.action.AdminActionPortlet.java

License:Apache License

/**
 * This is  function add edit Agency Manager
 * Version: 1.0/*w  ww . ja  va 2 s .  c  o m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void addEditCoQuanQuanLy(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    new CoQuanQuanLyAction().addEditCoQuanQuanLy(actionRequest, actionResponse);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.admin.portlet.action.AdminActionPortlet.java

License:Apache License

/**
 * This is  function edit or add role request
 * Version: 1.0//from   w w w.  ja  v a2  s.  co m
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void editOrAddVaiTroRequest(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    VaiTroAction action = new VaiTroAction();
    action.editOrAddVaiTroRequest(actionRequest, actionResponse);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}

From source file:org.oep.cmon.admin.portlet.action.AdminActionPortlet.java

License:Apache License

/**
 * This is  function edit ? add role request
 * Version: 1.0/*from   w w  w  .  j ava  2s .co  m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param actionRequest
 * @param actionResponse
 * @throws Exception
 */
public void editOrAddChucVuVaiTroRequest(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {
    ChucVuVaiTroAction action = new ChucVuVaiTroAction();
    action.editOrAddChucVuVaiTroRequest(actionRequest, actionResponse);
    PortletConfig portletConfig = (PortletConfig) actionRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
    SessionMessages.add(actionRequest,
            portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
}