Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

andres matus

+ Follow
since Dec 21, 2007
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by andres matus you'r getting to my point. I wasnt saying that you have to comment the validator method, it was just to prove i'm right. Although the validator method is meant to be called when you submit a form, when you use it on a jsp page, it always called the validation and reset method, always!!, even if it's the first time you access it, just make a debug and you will see it. you'r options are, set the propertie with a default value (i.e. "") or just simply use validator framework, thats the best practice you can do. If you decide to do it, your form dont have to extend two clases, because it will no longer extend ActionForm, it will just extend ValidatorForm, that is a subclass of the struts form class. That form extending ValidatorForm dont need the validator method or the reset method, because uses the method of the super class. So you just need to get into the validator framework and you should be able to solve your problem.
14 years ago
i'm pretty sure that if you comment your validate method the problem is solved. Now the issue is what do you want to validate and when. The best practice is to use validator framework, your action form should extend ValidatorForm and the super class will handle the validation with the default validators.
14 years ago
you get that error because the propertie you want to display on the page doesn't have the getter and setter method on the FORM.

Be carefull to do that with every propertie you declare con the form.
14 years ago
that's because the validate method of the form is called every time you instance the form, and that occurs when a page is requested. So any time you are accessing a page you are going to get the validation (and the reset). If you whant to use the validation that way shouldn't validate for null or set the propertie to some value by defualt.

Other way is to use the validator framework provided with struts.
14 years ago
it's easier if you do it with html and javascript because you can put each element the...onmousover="" event to do whatever you want. for example

make a list...

<ul class="alignment">
<li onnmousover="tooltip()" > Element 1 </li>
<li onnmousover="tooltip()" > Element 2 </li>
<li onnmousover="tooltip()" > Element 3 </li>

change the onnmousover for the correct event!!!

and with css you can make that list to be vertical or horizontal
if you need to be a tree and make it collapse then you need to implement it with javascript.

To handle this you need an array propertie on your form, so that way when you select items on the list that array is set with the values from the list.

private String[] listValues;
14 years ago
ok then....finally we get there

whe need a lot of work here so i hope you can implement it....

We are going to use struts-menu...

Step 1.

Include the struts-menu library in your proyect class path (i'm using version 2.4.2).

Step 2.
Setting the plug-in in the struts-config.xml...

< plug-in className="" >
<set-property property="menuConfig" value="/WEB-INF/menu-config.xml"/>
</plug-in >

the menu-config.xml file is the configuration for the gonna get it is an example...

<?xml version="1.0" encoding="UTF-8" ?>
<Displayer name="ListMenu" type="yourpackage.ListMenuDisplayer" />

the ListMenuDisplayer is the class that build the menu....

public class ListMenuDisplayer extends MessageResourcesMenuDisplayer {
//~ Instance fields ========================================================

//~ Methods ================================================================

public void init(PageContext pageContext, MenuDisplayerMapping mapping) {
super.init(pageContext, mapping);


public void display(MenuComponent menu) throws JspException, IOException {
if (isAllowed(menu)) {
if(menu.getParent() == null)
out.println("<ul width=\"150px\">");
displayComponents(menu, 0);
displayComponents(menu, 0);

protected void displayComponents(MenuComponent menu, int level)
throws JspException, IOException {

MenuComponent[] components = menu.getMenuComponents();

if(menu.getParent() == null )
out.print("<li >");
out.println("<h2 style=\"font-size: 14px;\">");
for (int i = 0; i < components.length ; i++ )
if(components.length > 0)
out.println("<li><a class=\"x\" style='font-size:13px;'>");
for (int i = 0; i < components.length ; i++ )
if(menu.getLocation() != null)
out.println("<li><a href=\" " + menu.getLocation() +" \" style='font-size:13px;'>");
out.println("<li><a onKlick=\" " + menu.getLocation() +" \" style='font-size:13px;'>");
out.println("<li><a disabled style='color: gray; cursor: default;font-size: 12px;' >");


* This will output the ending HTML code to close tags from the beginning
* @param context the current pageContext
public void end(PageContext context) {
try {
} catch (Exception e) {

public String getExtra(MenuComponent menu) {
StringBuffer extra = new StringBuffer();
if (menu.getTarget() != null) {
extra.append(" target=\"").append(menu.getTarget()).append("\"");
if (menu.getOnclick() != null) {
extra.append(" onklick=\"").append(menu.getOnclick()).append("\"");
if (menu.getOnmouseover() != null) {
extra.append(" onmousover=\"").append(menu.getOnmouseover()).append("\"");
if (menu.getOnmouseout() != null) {
extra.append(" onmousout=\"").append(menu.getOnmouseout()).append("\"");
if (menu.getWidth() != null) {
extra.append(" style=\"width: " + menu.getWidth() + "px\"");
return (extra.length() > 0) ? extra.toString() : "";

this class is renders the menu when you declare it...i will do this later...

Step 3.

Now you need to build the menu based on your information from the data base, if you have functions then the only hing you need is to make a list of that and iterate through them to build it. Also you can define the link of the menu, and set it on the location of the menu component...

You can build the menu from any class you whant, i did it at the login class, so when the user logs in the menu is built and at the redirect is available.....put this lines where you whant to build it....

//declaring the repository
MenuRepository repository = new MenuRepository();
//getting the displayers info from the xml file
MenuRepository defaultRepository = (MenuRepository)


//class MenuBuilder that i create, see next class...
MenuBuilder menuBuilder = new MenuBuilder();

repository = menuBuilder.buildMenu(user,repository,allFunctions);

//after you build the menu put it on the session so you dont have to rebuildit again...improving performance...


/*** Getting inside the menu building steps ***/
MenuBuilder class

public class MenuBuilder

public MenuRepository buildMenu(Users us,MenuRepository rep,List functions)

List allFunctions = functions;
Hashtable userFunctions = new Hashtable();
Hashtable titulosNoRepetidos = new Hashtable();

//Class that set the cmenu component...see next class
MenuDisplay md = new MenuDisplay();

Iterator it0 = allFunctions.iterator();
//Functions is an object that haves the title and link of the menu.
Functions function = (Functions);
rep.addMenu(md.menuDisplay(function, rep));
return rep;


public class MenuDisplay
public MenuDisplay()

public MenuComponent menuDisplay(Functions function,MenuRepository repository)
MenuComponent mc = new MenuComponent();
String name = function.getItemName();
String parent = function.getParentName();

if (parent != null) {
MenuComponent parentMenu = repository.getMenu(parent);
if (parentMenu == null) {
// create a temporary parentMenu
parentMenu = new MenuComponent();
String title = function.getItemTitle();
String location = null;

if(function.getItemLocation() != null && !(function.getItemLocation()).startsWith("window"))
location = function.getItemLocation();
location = null;
location = function.getItemLocation(); }
return mc;
} this point you should be able to have the carefull to make the Data base structure to the menu, you at least need a name,location,and parent, to have a tree relation of the menu.

Now we need to display the menu on the jsp pages....

Step 4.

i made a .jspf page (that is a fragment of a jsp...) and include it in all other jsp pages where i need the menu to be displayed.


<%@ taglib uri="" prefix="c"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="" prefix="menu" %>
<%@ taglib uri="" prefix="menu-el" %>

<% repository = ("repository"));
<table width="1270px" >
<div id="menu">
<menu-el:useMenuDisplayer name="ListMenu" repository="repository" >
<logic:iterate id="headers" name="repository" property="topMenus" type="">
<c:if test="${ != null}">
<menu-el isplayMenu name="${}" />

this jspf page display the menu iterating over the repository you set up on the session on step 2....

so now the only thing you need to do is include this jspf page into others jsp pages to see the menu....
<%@ include file="menu.jspf"%>

and thats it.....

hope i could help you with this....

gonna what for your reply....
14 years ago
you need to have 2 files...validation.xml and validator-rules.xml.


<form name="FormName">
depends="required"> <!-- validation -->

the depends field are the names that you have on the validator-rules.xml for each validator.

Your action form need to extends ValidatorForm class, and you dont need the validator method on it.

in Struts-config you need to put on the action field the imput param (where the input comes from)..and the validate='true' param

in your jsp you should include the error tag to see the error messages

<html:error />
14 years ago
are you shure you are updating the text field on the ajax call ???....because the only thing you have to do is to set the fare propertie of the action.


and then if you are updating the textfield the propertie fare should have the new value and show it on the text.
14 years ago
you need to set the onmouseover event in the element you whant to show the tooltip. It would be easier if you have html elements to display the drop down menu.
you should include the <html:error /> tag...that way you would be able to see the error messages.
14 years ago
a DB based menu is a Data Base based menu, wich means that all the topics in the menu are obtained from a data base, that way you make your menu be dynamic. On the other hand if you dont need a dynamic menu, you can build it with javascript, or with html lists and give'em style with css.

First off all you need to tell what kind of menu do you need.

If one requirement is to have diferent menus for diferent users, you should have each menu related with the users.

I did this a few time a be more especific to be able to help you.
14 years ago
First off all you have to know what kind of menu do you want. If it�s a DB based menu, or a static menu, and depending of that select the best way to implement it. In most cases you can choose javascript and get really cool menus, but my suggest is to use struts-menu, you can do almoust everything with that.

take a look at
14 years ago
you can put a user object in the request session...that way you have the user information all over your app.

use this....
//setting the user information on the session

//reading the user information from the session
UserObject user = (UserObject)request.getSession().getAttribute("UserSession");
14 years ago
Hi all...

i'm trying to implement security on my struts app, but i dont know how to set groups and roles to the app to identify if a user is in some role...
14 years ago