Showing posts with label Struts. Show all posts
Showing posts with label Struts. Show all posts

Friday, March 11, 2011

Remove dot infront of actionerror and actionmessage in Struts2

You can see the dot symbol infront of actionError and actionMessages while displaying your result in jsp page.

This is because of placing <s:actionerror />  and <s:actionmessages />  directly into your jsp page.
Actionerror and Actionmessage displays result in un-ordered list format.
Your Error or Message in the following format

1) . Action Error
2) . Action Message

Inorder to remove the dot symbol place the <s:actionerror> and <s:actionmessage> inside <s:if> condition


   


   
div class="errors" and div class="messages" are not mandatory.
Both are css classes.
Dot symbol will get removed and you will get the expected result.

For more java programming click this Link.
Do post your comments

Thursday, January 27, 2011

Struts2 Select Box Error.

I believe you faced this error thats why you are here for the solution.
Instead of wasting our time straightly we will go to the solution.

struts.xml

  /jsp/selectBox.jsp  


SelectList.java
package com.demo.actions;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class SelectList extends ActionSupport{
private ArrayList dayList;
public String execute() throws Exception {
//instantiate the Arraylist here
dayList = new ArrayList();
dayList.add("monday");
dayList.add("tuesday");
...
dayList.add("sunday");
return SUCCESS;
}
//Make sure you have created the getter and setter method for ArrayList
public ArrayList getDayList() {
  return dayList;
 }
public void setDayList(ArrayList dayList) {
  this.dayList= dayList;
 }
}
selectBox.jsp
Thats it your code will work like a charm.
Do post your comments and for more java programming click this Link.