Mark, It is my 1st trial of using Tiles. I do not know how to choose. What are you using? Could you show me some fragment codes with struts-defs.xml, struts-config.xml action or controllerSomething?
Thanks On Wed, 27 Oct 2004 17:26:55 +0200, Mark Lowe <[EMAIL PROTECTED]> wrote: > Decide if you want to use an action or a tiles controller.. Or a tiles action.. > > You can use an action if you return null rather than a forward (well > for a forward) and use the controllor url attribute. But this means > wiring an an action and a tile/ controllorUrl="/myaction.do" > > Mark > > > > On Wed, 27 Oct 2004 23:22:03 +0800, PC Leung <[EMAIL PROTECTED]> wrote: > > Error messages display as follows. > > > > [ServletException in:/layout/menu.jsp] null' > > java.lang.ClassCastException at > > org.apache.jsp.layout.menu_jsp._jspService(menu_jsp.java:193) at > > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) > > ... > > ... > > > > after adding a few lines to test in the following class, > > > > public final class MyMenuAction extends TilesAction implements Controller { > > public ActionForward perform( ComponentContext context, > > ActionMapping mapping, > > ActionForm form, > > HttpServletRequest request, > > HttpServletResponse response) > > throws IOException, ServletException { > > perform( context, request, response, getServlet().getServletContext() ); > > return null; > > } > > public void perform(ComponentContext context, > > HttpServletRequest request, HttpServletResponse response, > > ServletContext servletContext) > > throws ServletException, IOException { > > List menuItems = (List) context.getAttribute("items"); // > > menuItems.add("customize1"); > > // this few lines > > menuItems.add("customize2"); // > > context.putAttribute("items", menuItems); // > > ... > > > > Struts-defs.xml: > > <definition name="erp.menu.home" path="/layout/menu.jsp" > > controllerClass="com.common.tiles.MyMenuAction" > > > <put name="title" value="Tiles" /> > > <putList name="items" > > > <item value="customize1" link="/Welcome1.jsp" /> > > <item value="customize2" link="/Welcome2.jsp" /> > > </putList> > > </definition> > > > > How can I add a few lines of creating a list to test the menu? > > > > Thanks > > > > On Tue, 26 Oct 2004 19:57:49 +0200, Mark Lowe <[EMAIL PROTECTED]> wrote: > > > To do what you want you want a tiles controller, not an action. > > > > > > import org.apache.struts.tiles.ComponentContext; > > > import org.apache.struts.tiles.ControllerSupport; > > > import org.apache.struts.tiles.beans.SimpleMenuItem; > > > import java.util.List; > > > import javax.servlet.ServletContext; > > > import javax.servlet.ServletException; > > > import javax.servlet.http.HttpServletRequest; > > > import javax.servlet.http.HttpServletResponse; > > > import javax.servlet.http.HttpSession; > > > > > > public class GroupController extends ControllerSupport { > > > public void execute(ComponentContext tileContext, > > > HttpServletRequest request, HttpServletResponse response, > > > ServletContext context) throws Exception { > > > > > > List menuItems = (List) context.getAttribute("items"); > > > > > > .. add some menu items. > > > > > > context.putAttribute("items", menuItems); > > > } > > > } > > > > > > I;d try and avoid using a tiles controller as exception handling is an > > > arse. Perhaps look at having a BaseAction that adds teh relevant items > > > into the request. > > > > > > public abstract class BaseAction extends Action { > > > > > > protected abstract ActionForward doExecute(ActionMapping mapping, > > > ActionForm form, HttpServletRequest request, > > > HttpServletResponse response) throws Exception; > > > > > > public ActionForward execute(ActionMapping mapping, ActionForm form, > > > HttpServletRequest request, HttpServletResponse response) > > > throws Exception { > > > .. > > > request.setAttribute("items",menuItems); // perhaps application > > > scope > > > > > > return doExecute(mapping, form, request, response); > > > } > > > } > > > > > > Now execute will be run for ever class that subclasses it, and they > > > will have to use the doExecute(), method.. For more details check the > > > xpetstore project out that uses this technique. This approach will > > > allow you to make use of exception handlers. > > > > > > Mark > > > > > > > > > > > > > > > On 26 Oct 2004, at 17:14, PC Leung wrote: > > > > > > > Hello world, > > > > > > > > The following is a fragment of tiles-defs.xml. > > > > where MyMenuAction actually is UserMenuAction in Tiles. > > > > > > > > <definition name="erp.menu.home" path="/layout/menu.jsp" > > > > controllerClass="com.common.tiles.MyMenuAction" > > > > > <put name="title" value="Tiles" /> > > > > <putList name="items" > > > > > <item value="customize" link="/Welcome.jsp" /> > > > > ^^^^^^^^^^ ^^^^^^^^^^^^^^^ > > > > </putList> > > > > </definition> > > > > > > > > Where and how should I put the coding inside MyMenuAction > > > > so that I can add a number of items which behaves as > > > > a list of menu item? > > > > > > > > Thanks > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]