1 18 19 package org.apache.struts.webapp.tiles.dynPortal; 20 21 import javax.servlet.ServletException ; 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 import javax.servlet.http.HttpSession ; 25 import org.apache.struts.action.Action; 26 import org.apache.struts.action.ActionForm; 27 import org.apache.struts.action.ActionForward; 28 import org.apache.struts.action.ActionMapping; 29 import org.apache.struts.tiles.ComponentContext; 30 31 32 38 39 public final class SetPortalPrefsAction extends Action { 40 41 42 44 45 60 public ActionForward execute( 61 ActionMapping mapping, 62 ActionForm form, 63 HttpServletRequest request, 64 HttpServletResponse response) 65 throws Exception  66 { 67 System.out.println("Enter action SetPortalPrefsAction"); 68 HttpSession session = request.getSession(); 69 PortalPrefsForm prefsForm = (PortalPrefsForm)form; 70 71 ComponentContext context = ComponentContext.getContext( request ); 73 if( context == null ) 74 { 75 throw new ServletException ( "This action must be called by a Tile, not directly" ); 76 } 77 78 PortalSettings settings = RetrievePortalAction.getSettings( context, session ); 80 81 if( prefsForm.isSubmitted() ) 82 { System.out.println("form submitted"); 84 85 for( int i=0;i<prefsForm.getNumCol(); i++) 87 { 88 settings.resetListAt( i, prefsForm.getNewCol(i)); 89 } 91 92 prefsForm.reset(); 95 return (mapping.findForward("portal")); 96 } 97 98 for( int i=0;i<settings.getNumCols(); i++ ) 100 { 101 prefsForm.addCol(settings.getListAt(i) ); 102 prefsForm.addColLabels(settings.getListLabelAt(i) ); 103 } 105 prefsForm.setChoices(settings.getChoices() ); 106 prefsForm.setChoiceLabels(settings.getChoiceLabels() ); 107 108 System.out.println("Exit action SetPortalPrefsAction"); 109 return (mapping.findForward("preferences")); 110 } 111 112 113 } 114 | Popular Tags |