HASHMAP IN STRUTS!!!!!!!

I am working with hashmap in the file .java and it passage to the jsp page. The problem is that I don't know how they treat hashmaps in struts. I have fact this:
<% pageContext.setAttribute("edadesSexo", dto.get("edades")); %>
<logic:iterate id="dtoi" name="edadesSexo" collection="edadesSexo">
<% interfaz.GenericDto dtoEA = (interfaz.GenericDto)dtoi; %>
<% if (dtoEA != null){ %>
<tr>
<td><%= dtoEA.get("edad")%></td>
<td><%= dtoEA.get("ctotal")%></td>
</tr>
<% }; %>
</logic:iterate>
and he throws the following error to me, in the jsp page: "interfaz.GenericDto"
well, I hope that you can help me!
Thank you very much!
ANDRE

Yes, in the file java, to iterar in hashmap I have this it works very well:
for (Iterator k = edadesSexo.keySet().iterator(); k.hasNext();){
Integer tmpInt=(Integer)k.next();
CMEdadYSexo name = (CMEdadYSexo)edadesSexo.get(tmpInt);
GenericDto dtoe = new GenericDto();
dtoe.put("edad",new Integer(name.getEdad()));
dtoe.put("ctotal",new Integer(name.getCantEdad()));
edadesSexo.put(tmpInt,dtoe);
the problem I have it when shipment that one hashmap to jsp because I don't know how struts treats to hashmaps... I do not know how to accede to its elements (which are dto's)

Similar Messages

  • Struts Hashmap

    I'm trying to use a HashMap in Struts but cannot work out why the setPrivilege() method is never called when the form is submitted.
    Everything seems to be in order as the values are retrieved okay from the Hashmap for display on the form and other properties of the form are set correctly on submission.
    Any ideas??
    <td style="text-align:center;">
    <bean:define name="group" id="id" property="groupID" />
    <html:text property="privilege(${id})" size="4" />
    </td>
    public void setPrivilege(String key, Object value)
         System.out.println("called");
         map.put(key, value);
    public String getPrivilege(String key)
         return (String)map.get(key);
    }

    Okay, fixed.
    public void setPrivilege(String key, Object value)
         map.put(key, value);
    public Object getPrivilege(String key)
         return map.get(key);
    }

  • URGENT, please!!!! can anyone help me with this error...

    "ERROR EN PAGINA JSP : Cannot create iterator for this collection"
    I wanted to know how to access to the elements of hashmap from struts? In the file .java I have a HashMap which it passage in dto to show it in the jsp page. That is to say, the dto of jsp contains hashmap and I want to know I accede it...
    Note: the elements that hashmap contains are dto's.
    In the jsp page I've this:
    <logic:iterate id="dtoi" name="ages" collection="ages.keySet()" indexId="dtoi">
    <% interfaz.GenericDto dtoEA = (interfaz.GenericDto)dtoi; %>
    <% if (dtoEA != null){ %>
    <% }; %>
    </logic:iterate>
    but the error is above... :(
    Thanks very much!!
    and

    <logic:iterate id="dtoi" name="ages"
    collection="ages.keySet()" indexId="dtoi">
    <% interfaz.GenericDto dtoEA =
    (interfaz.GenericDto)dtoi; %>
    <% if (dtoEA != null){ %>
    <% }; %>
    </logic:iterate> Try the following (assuming "ages" is the HashMap - adjust as necessary):
    <logic:iterate id="dtoi" name="ages">
    <tr>
    <td><bean:write name="dtoi" property="value.edad"/></td>
    <td><bean:write name="dtoi" property="value.ctotal"/></td>
    </tr>
    </logic:iterate>

  • Displaying Hashmap values in JSP using struts taglib

    Please can any one provide me the solution for the below query,
    I have stored hasmap key as string and value as arraylist, can any one suggest how to display the hashmap values(arraylist) in table format in jsp using struts taglib.
                             HashMap hsMap=new HashMap();
                             ArrayList arrList = new ArrayList();
                             arrList.add("filesize");
                             arrList.add("filelength");
                              hsMap.put("filename",arrList);
               In jsp i want to display filename and filesize in table format.

    Read this documentation:
    http://struts.apache.org/struts-doc-1.2.x/userGuide/struts-logic.html#iterate

  • Display HashMap values in JSP using Taglib in struts

    Hi ,
    I am new to struts and JSTL. I am developing Discussion Forums using Struts.
    I have HashMap object with(key & values) in My Action class.
    I want to diplay in my JSP as a List with html:links to do other process.
    How can I display HashMap values in my JSP. Which is the best way to display
    My intenetion is maxmum avoiding <%%> code in jsp.
    Which is the best way to display ?
    Can I diplay using taglib which is generic tag for any collection object ?
    Can any one help me ASAP.
    thanks
    Chandra

    Hi Riaz,
    You can use same code in JSP
    Java Code
    import java.util.*;
    class TestHashMap
    public static void main(String args[])
    HashMap hm=new HashMap();
    //store some Objects.
    hm.put("Rajib Sarma","100");
    //duplicate keys are not allowed.
    hm.put("Rajib Sarma","200");//The value "100" is replaced by "200".
    hm.put("Sazid Ahmed","200");
    //Display the contents of the HashMap
    System.out.println("Displaying all the keys/values.\r\n");
    System.out.println("Key\t\tValue\r\n");
    //get all the keys
    Collection c=hm.keySet();
    //obtain an Iterator
    Iterator i=c.iterator();
    while(i.hasNext())
    //obtain a key
    Object key=i.next();
    //obtain the value of the key
    Object value=hm.get(key);
    System.out.println(key +"\t" + value);
    }//while ends
    }//main ends
    }

  • Java.util.HashMap cannot be cast to org.apache.struts.action.ActionForm

    Hi!
    anybody could help me?
    i am getting java.util.HashMap cannot be cast to org.apache.struts.action.ActionForm error when I run my jsp...
    heres my code :
    CommentAction.java
    package com.provintl.rmis.actions;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Date;
    import java.util.HashMap;
    import java.util.Map;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.sql.DataSource;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import com.provintl.rmis.forms.CommentForm;
    public class CommentAction extends Action {
         Statement stmt = null;
         Connection con = null;
         javax.sql.DataSource dataSource;
         PreparedStatement ps = null;
         ResultSet rs=null;
         byte updFlg = 0;
         Map commentlist = new HashMap();
         /* (non-Javadoc)
         * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
         @Override
         public ActionForward execute(ActionMapping mapping, ActionForm form,
                   HttpServletRequest request, HttpServletResponse response)
         throws Exception {
              CommentForm commentForm = new CommentForm();
              Date date = commentForm.getDaterecord();
              String comment = commentForm.getComment();
              //TODO : temporary 1 == rose
              int userID =1;
              int appID =1;
              String SelectQry = "SELECT "+
                                       "APPLICANT_TBL.CHFNAME, "+
                                       "APPLICANT_TBL.CHLNAME, "+
                                       "APPLICANT_TBL.INTAPPID, "+
                                       "USERHST_TBL.CHCOMMENT, "+
                                       "USERHST_TBL.DTDATECREATED, "+
                                       " USERHST_TBL.INTHSTID "+
                                       "FROM "+
                                       "APPLICANT_TBL "+
                                       "INNER JOIN USERHST_TBL ON (APPLICANT_TBL.INTAPPID = USERHST_TBL.INTAPPID) " +
                                       "WHERE APPLICANT_TBL.CHFNAME ='"+request.getParameter("first")+"' " +
                                                 "AND APPLICANT_TBL.CHLNAME ='"+request.getParameter("last")+"'";
              try {
                   dataSource = (DataSource)getDataSource(request, "RMIS");
                   con = dataSource.getConnection();
                   con.setAutoCommit(false);
                   stmt = con.createStatement();
                   System.out.println("database connected");
                   rs = stmt.executeQuery(SelectQry);
                   System.out.println("database connected");
                   int ctr = 1;
                   while(rs.next()){
                        commentlist.put(ctr,new CommentForm(rs.getString("CHFNAME"),rs.getDate("DTDATECREATED")));
                        ctr++;
                   if(updFlg !=0){
                        String insQry = "INSERT INTO RECRUIT.USERHST_TBL (CHCOMMENT, INTUSERID, INTAPPID)" +
                        "VALUES ('"+comment+"',"+userID+","+appID+")";
                        stmt.executeUpdate(insQry);
                        con.commit();
                        updFlg = 0;
                   HttpSession session = request.getSession();
                   session.setAttribute("commentlist", commentlist);
                   //con.setAutoCommit(true);
              } catch (SQLException se) {
                   System.out.println("We got an exception while preparing a statement:" +
                   "Probably bad SQL.");
                   System.out.println(SelectQry);
                   se.printStackTrace();
                   //System.exit(1);
              finally {
                   try {
                        rs.close();
                        stmt.close();
                        con.close();
                   } catch (SQLException e) {
                        e.printStackTrace();
              return mapping.findForward("comment");
    commentform.jsp
    =============
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html"     prefix="html"%>
    <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jstl/sql_rt" prefix="sql"%>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script>
    function putLabel(lbl, formName){
    if (opener && !opener.closed){
    opener.document.addapp.jobposition.value=lbl;
    window.close();
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>List of open positions</title>
    </head>
    <body>
    <h2>Job Positions Available</h2>
    <%
    int ctr = 1; %>
    <logic:iterate id="myString" name="commentlist" scope="session">
    <table width="100%" border="0">
    <%
    String bakcolor;
    if((ctr % 2) == 0){
         bakcolor = "WHITE";
         ctr++;
    else{
         bakcolor = "SILVER";
         ctr++;
    %>
    <tr><td bgcolor="<%= bakcolor %>">
    <bean:write name="myString" property="value" />
    </td></tr>
    ${commentlist}
    </table>
    </logic:iterate>
    </body>
    </html>
    thank you in advance!

    Shilnag wrote:
    Hello guys,
    I am new to java... I am trying to develop a web application using
    1.Struts1.2
    2.tomcat 5.5
    3.eclipse 3.2.2Big mistake. Nobody new to Java should jump straight into webapps, let alone using a framework like Struts. Debatably, even Eclipse should be left alone.
    It's precisely because of this that you're having problems. Presumably you're following a tutorial or something, but - as demonstrated - as soon as it goes wrong, you're stuck. Learn some core Java first, trust me

  • Using HashMap's ContainsKey() in JSTL

    Can we use HashMap's containsKey() in JSTL <c:if > statement
    I tried with the sample
    <html:select property="Type" multiple = "true" size = "3">
    <option value='<c:out value="${key}"/>'
    <c:if test="${requestScope.test.containsKey(key)}">
    selected
    </c:if>     
    <c:out value="${value}"/></option>
    </html:select >
    When i executed the above code i encountered JSP Error
    Can any one please let me know the correct code

    You can't call java methods from JSTL. It uses the EL - not java.
    However there is a solution.
    You access maps using the square brackets [ ] notation.
    ie ${test[key]}
    is the same as test.get(key)
    try
    <c:if test="${ not empty test[key] }"/>
    However seeing as you are using the struts tags, doesn't that automatically take care of this for you? Why don't you use the struts tags for the options list as well as the select? Just a thought :-)
    Cheers,
    evnafets

  • Dynamic forms in struts

    Hi,
    I have a pretty difficult problem that I don't know how to solve using struts. I need to generate dynamic surveys from a database. The structure of the survey can be different for every different user. I really want to use the struts Form classes but I'm not sure how to do this. The only way I can think of is messy...
    For every new type of survey generated from the database...
    1. Generate a new class definition for the struts Form object and compile that.
    2. Every struts Action class that interacts with the new dynamic Form classes will need to use reflection on the dynamic Form object to be able to pull all of the data from that form.
    I'm sure there are many web sites where forms are dynamically generated and I would think this problem has already been solved. Does anyone out there have any ideas?

    Try to follow this way:
    1 provide actions chain in your configuration file like this:
             <form-bean
                  name="addFlatForm"
                  type="app.owner.forms.AddFlatForm">
                </form-bean>
            <action
                 path="/InitAddFlatForm"
                 type="app.owner.actions.InitAddFlatFormAction"
                 attribute="addFlatForm"
                 validate="false"
                 parameter="owner.extendedplace;place;/pages/AddFlat.jsp">             
            </action>
            <!-- "/pages/AddFlat.jsp" - jsp page with html:form on it-->     
            <action
                 path="/AddFlatForm"
                 type="app.owner.actions.AddFlatAction"
                 name="addFlatForm"
                 validate="true"
                 input="/pages/AddFlat.jsp">
                 <forward
                      name="success"
                      path="/shortinfo/Welcome.do"></forward>
            </action>2 first action(InitAddFlatFormAction) will be "prepare" action, where you must create new instance of the ActionForm descendant with Map, List, array etc definition. where your dynamic fields will be located , and fill the keys value from your database.
    public class InitAddFlatFormAction extends Action{
         public ActionForward execute(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response){
              //obtain parameters
              String[] params = ActionHelper.parseParameter(mapping, 3, Constants.PARAMETER_SEPARATOR);
              //get extended place from session attribute
              ExtendedPlace currPlace = (ExtendedPlace)ServletUtils.getAttribute(
                        request, params[0], ServletUtils.SESSION_SCOPE);
              //create form if form == null
             if (form == null) {
                  System.out.println("InitAddFlatFormAction::execute method: create new instance of action form.");
                  //create new form instance
                  form = new AddFlatForm(new HashMap<String, Object>());
                  //set form to selected scope attribute
                if ("request".equals(mapping.getScope()))
                     ServletUtils.setAttribute(request,
                               form, mapping.getAttribute(), ServletUtils.REQUEST_SCOPE);   //just set the value to selected scope
                else
                     ServletUtils.setAttribute(request,
                               form, mapping.getAttribute(), ServletUtils.SESSION_SCOPE);   //just set the value to selected scope
             //fill the form
             AddFlatForm flatForm = (AddFlatForm) form;
             flatForm.setValue(params[1], currPlace);
             return URIUtils.forwardAction(params[2]);
         }3 second action(AddFlatAction) will be "process" action. This action can be used when your data are successful validated.
    //any your actions4 form bean(ActionForm desctndant)
    public class AddFlatForm extends ActionForm{
         public AddFlatForm(Map<String, Object> map){
              super();
              //check input arguments
              AssertHelper.notNullIllArg(map);
              setMap(map);
         private Map<String, Object> map = null;
         public void setMap(Map<String, Object> map) {
              this.map = map;
         public Map<String, Object> getMap() {
              return this.map;
         public void setValue(String key, Object value){
              getMap().put(key,value);
         public Object getValue(String key){
              return getMap().get(key);
        public ActionErrors validate(ActionMapping mapping,
                HttpServletRequest request) {
            return (null);
    }And than in your jsp page you can use something like this:
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
                                            <c:set var="placeId">
                                                 <bean:write name="extPlace" property="placeInfo.id"/>
                                            </c:set>
                                            <c:set var="groupId">
                                                 <bean:write name="groups" property="filterGroupInfo.id"/>
                                            </c:set>
                                            <c:set var="filterId">
                                                 <bean:write name="filters" property="filter.id"/>
                                            </c:set>
                                            <bean:message name="filters" property="filter.filterDescription"/>
                                            <html:text property="value(${placeId};${groupId};${filterId})"/>                                                                 Something like this are displayed in struts-example.war (example application for struts1.1)
    pay attention for classes
    EditRegistrationAction.java and SaveRegistrationAction.java
    sorry for bad english... :)

  • For Loop in Struts ?(without Collections)

    Hi all,
    Pls tell me how can v use FOR LOOP IN JSP STRUTS without using scriplets and collections .
    suppose i want to display 20 times "hello world "in jsp .How can i display it using STRUTS as conventionally scriplets are not allowed in it.
    and Iterator is only for Collections .
    thanx

    TestBean.java
    * $Id: TestBean.java 54929 2004-10-16 16:38:42Z germuska $
    * Copyright 1999-2004 The Apache Software Foundation.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    * http://www.apache.org/licenses/LICENSE-2.0
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    package org.apache.struts.webapp.exercise;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Vector;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.util.LabelValueBean;
    * General purpose test bean for Struts custom tag tests.
    * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
    public class TestBean extends ActionForm {
    // ------------------------------------------------------------- Properties
    * A collection property where the elements of the collection are
    * of type <code>LabelValueBean</code>.
    private Collection beanCollection = null;
    public Collection getBeanCollection() {
    if (beanCollection == null) {
    Vector entries = new Vector(10);
    entries.add(new LabelValueBean("Label 0", "Value 0"));
    entries.add(new LabelValueBean("Label 1", "Value 1"));
    entries.add(new LabelValueBean("Label 2", "Value 2"));
    entries.add(new LabelValueBean("Label 3", "Value 3"));
    entries.add(new LabelValueBean("Label 4", "Value 4"));
    entries.add(new LabelValueBean("Label 5", "Value 5"));
    entries.add(new LabelValueBean("Label 6", "Value 6"));
    entries.add(new LabelValueBean("Label 7", "Value 7"));
    entries.add(new LabelValueBean("Label 8", "Value 8"));
    entries.add(new LabelValueBean("Label 9", "Value 9"));
    beanCollection = entries;
    return (beanCollection);
    public void setBeanCollection(Collection beanCollection) {
    this.beanCollection = beanCollection;
    * A multiple-String SELECT element using a bean collection.
    private String[] beanCollectionSelect = { "Value 1", "Value 3",
    "Value 5" };
    public String[] getBeanCollectionSelect() {
    return (this.beanCollectionSelect);
    public void setBeanCollectionSelect(String beanCollectionSelect[]) {
    this.beanCollectionSelect = beanCollectionSelect;
    * A boolean property whose initial value is true.
    private boolean booleanProperty = true;
    public boolean getBooleanProperty() {
    return (booleanProperty);
    public void setBooleanProperty(boolean booleanProperty) {
    this.booleanProperty = booleanProperty;
    * A multiple-String SELECT element using a collection.
    private String[] collectionSelect = { "Value 2", "Value 4",
    "Value 6" };
    public String[] getCollectionSelect() {
    return (this.collectionSelect);
    public void setCollectionSelect(String collectionSelect[]) {
    this.collectionSelect = collectionSelect;
    * A double property.
    private double doubleProperty = 321.0;
    public double getDoubleProperty() {
    return (this.doubleProperty);
    public void setDoubleProperty(double doubleProperty) {
    this.doubleProperty = doubleProperty;
    * A boolean property whose initial value is false
    private boolean falseProperty = false;
    public boolean getFalseProperty() {
    return (falseProperty);
    public void setFalseProperty(boolean falseProperty) {
    this.falseProperty = falseProperty;
    * A float property.
    private float floatProperty = (float) 123.0;
    public float getFloatProperty() {
    return (this.floatProperty);
    public void setFloatProperty(float floatProperty) {
    this.floatProperty = floatProperty;
    * Integer arrays that are accessed as an array as well as indexed.
    private int intArray[] = { 0, 10, 20, 30, 40 };
    public int[] getIntArray() {
    return (this.intArray);
    public void setIntArray(int intArray[]) {
    this.intArray = intArray;
    private int intIndexed[] = { 0, 10, 20, 30, 40 };
    public int getIntIndexed(int index) {
    return (intIndexed[index]);
    public void setIntIndexed(int index, int value) {
    intIndexed[index] = value;
    private int intMultibox[] = new int[0];
    public int[] getIntMultibox() {
    return (this.intMultibox);
    public void setIntMultibox(int intMultibox[]) {
    this.intMultibox = intMultibox;
    * An integer property.
    private int intProperty = 123;
    public int getIntProperty() {
    return (this.intProperty);
    public void setIntProperty(int intProperty) {
    this.intProperty = intProperty;
    * A long property.
    private long longProperty = 321;
    public long getLongProperty() {
    return (this.longProperty);
    public void setLongProperty(long longProperty) {
    this.longProperty = longProperty;
    * A multiple-String SELECT element.
    private String[] multipleSelect = { "Multiple 3", "Multiple 5",
    "Multiple 7" };
    public String[] getMultipleSelect() {
    return (this.multipleSelect);
    public void setMultipleSelect(String multipleSelect[]) {
    this.multipleSelect = multipleSelect;
    * A nested reference to another test bean (populated as needed).
    private TestBean nested = null;
    public TestBean getNested() {
    if (nested == null)
    nested = new TestBean();
    return (nested);
    * A String property with an initial value of null.
    private String nullProperty = null;
    public String getNullProperty() {
    return (this.nullProperty);
    public void setNullProperty(String nullProperty) {
    this.nullProperty = nullProperty;
    * A short property.
    private short shortProperty = (short) 987;
    public short getShortProperty() {
    return (this.shortProperty);
    public void setShortProperty(short shortProperty) {
    this.shortProperty = shortProperty;
    * A single-String value for a SELECT element.
    private String singleSelect = "Single 5";
    public String getSingleSelect() {
    return (this.singleSelect);
    public void setSingleSelect(String singleSelect) {
    this.singleSelect = singleSelect;
    * String arrays that are accessed as an array as well as indexed.
    private String stringArray[] =
    { "String 0", "String 1", "String 2", "String 3", "String 4" };
    public String[] getStringArray() {
    return (this.stringArray);
    public void setStringArray(String stringArray[]) {
    this.stringArray = stringArray;
    private String stringIndexed[] =
    { "String 0", "String 1", "String 2", "String 3", "String 4" };
    public String getStringIndexed(int index) {
    return (stringIndexed[index]);
    public void setStringIndexed(int index, String value) {
    stringIndexed[index] = value;
    private String stringMultibox[] = new String[0];
    public String[] getStringMultibox() {
    return (this.stringMultibox);
    public void setStringMultibox(String stringMultibox[]) {
    this.stringMultibox = stringMultibox;
    * A String property.
    private String stringProperty = "This is a string";
    public String getStringProperty() {
    return (this.stringProperty);
    public void setStringProperty(String stringProperty) {
    this.stringProperty = stringProperty;
    * An empty String property.
    private String emptyStringProperty = "";
    public String getEmptyStringProperty() {
    return (this.emptyStringProperty);
    public void setEmptyStringProperty(String emptyStringProperty) {
    this.emptyStringProperty = emptyStringProperty;
    * A single-String value for a SELECT element based on resource strings.
    private String resourcesSelect = "Resources 2";
    public String getResourcesSelect() {
    return (this.resourcesSelect);
    public void setResourcesSelect(String resourcesSelect) {
    this.resourcesSelect = resourcesSelect;
    * A property that allows a null value but is still used in a SELECT.
    private String withNulls = null;
    public String getWithNulls() {
    return (this.withNulls);
    public void setWithNulls(String withNulls) {
    this.withNulls = withNulls;
    * A List property.
    private List listProperty = null;
    public List getListProperty() {
    if (listProperty == null) {
    listProperty = new ArrayList();
    listProperty.add("dummy");
    return listProperty;
    public void setListProperty(List listProperty) {
    this.listProperty = listProperty;
    * An empty List property.
    private List emptyListProperty = null;
    public List getEmptyListProperty() {
    if (emptyListProperty == null) {
    emptyListProperty = new ArrayList();
    return emptyListProperty;
    public void setEmptyListProperty(List emptyListProperty) {
    this.emptyListProperty = emptyListProperty;
    * A Map property.
    private Map mapProperty = null;
    public Map getMapProperty() {
    if (mapProperty == null) {
    mapProperty = new HashMap();
    mapProperty.put("dummy", "dummy");
    return mapProperty;
    public void setMapProperty(Map mapProperty) {
    this.mapProperty = mapProperty;
    * An empty Map property.
    private Map emptyMapProperty = null;
    public Map getEmptyMapProperty() {
    if (emptyMapProperty == null) {
    emptyMapProperty = new HashMap();
    return emptyMapProperty;
    public void setEmptyMapProperty(Map emptyMapProperty) {
    this.emptyMapProperty = emptyMapProperty;
    // --------------------------------------------------------- Public Methods
    * Reset the properties that will be received as input.
    public void reset(ActionMapping mapping, HttpServletRequest request) {
    booleanProperty = false;
    collectionSelect = new String[0];
    intMultibox = new int[0];
    multipleSelect = new String[0];
    stringMultibox = new String[0];
    if (nested != null)
    nested.reset(mapping, request);
    }

  • How to get first item of hashMap w/out knowing the key

    Hi
    can someone tell me if there is a way to get first item from a hashMap when you dont know what the key is. as the get method expects a defined 'key'
    reason I am asking this:
    I am using struts 2 UI <s:radio> tag. this tag takes a hashmap and creates radio maps. it has a 'value' attribute and if something is passed to this attribute then that radio button is checked by default. the list that contains radio buttons is created dynamically so i dont know what is actually in the hashMap key's. but i do know that key's are string.
    so just wondering if there is a way to get first item from a hashmap without knowing the key...

    thanks for the quick reply.
    posted in java forums because thought it was a java API/workaround question. gave a little history because i didnt want people to start questioning my use of HashMap for this purpose..
    anywhose..i've found a workaround.
    If someone has a similar problem:
    as the hashmap is being populated dynamically....set a String member of class to contain the first key thats being put in the hashmap. then have struts tag pick up that value.
    also, through your post and reading hashMap api...its usefull to know that hasMaps do not gurantee the order of elements in it. So now I am using a TreeMap.
    Thanks

  • Struts - How not to lose parameter after validate() method

    Hi
    I have following problem. When I submit a form(action= sendMessage.do) from site generated in writeMessage.do?id=1 action and validate method find errors it forwards to writeMessage.do I need to forward to writeMessage.do?id=1
    <action path="/sendMessage"
    type="SendMessageAction"
    name="writeMessageForm"
    scope="request"
    validate="true"
    input="/writeMessage.do">
    <forward name="ok" path="/info.jsp"/>
    </action>
    I need something like input="/writeMessage.do?id=xx" , but xx will be changing in runtime. How to solve that problem?

    Swap input="/writeMessage.do" with input="/sendMessage.jsp" (or whatever the name of the input JSP was). If I remember rightly this will fix it for the automatic validation errors, however you'll still get this problem if you need to test business rules/custom validation rules from within your application. To fix this copy the following class and specify a className attribute for your action element in the struts config
    i.e. <action ... className="com.whatever.CustomActionMapping" ... />
    package com.whatever
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class CustomActionMapping extends ActionMapping
        public ActionForward findForward(String forwardName, HashMap requestParams)
            ActionForward fwd = findForward(forwardName);
            Iterator iter1 = requestParams.keySet().iterator();       
            if (iter1.hasNext())
                StringBuffer basePath = new StringBuffer(fwd.getPath());           
                basePath.append("?");
                 while (iter1.hasNext())
                     String paramName = (String) iter1.next();
                     ArrayList paramValues = (ArrayList) requestParams.get(paramName);
                     Iterator iter2 = paramValues.iterator();
                     while (iter2.hasNext())
                         String paramValue = String.valueOf(iter2.next());
                          basePath.append(paramName);
                          basePath.append("=");
                          basePath.append(paramValue);
                          if (iter2.hasNext())
                              basePath.append("&");
                     if (iter1.hasNext())
                         basePath.append("&");
                 fwd = new ActionForward(fwd);
                 fwd.setPath(basePath.toString());
            return fwd;
    }Then in the execute method of your action do something like
    // Creates a map to store the request parameters in
    HashMap requestParams = new HashMap();
    // Helper method to extract a request parameter for 'teamId'
    Integer teamId = RequestHelper.getTeamIdParam(request);       
    // Adds the teamId parameter to the hash map
    setRequestParam(RequestHelper.TEAM_ID, teamId, requestParams);
    // Creates a new forward with the required request parameters dynamically appended to the forward path
    return ((CustomActionMapping) mapping).findForward(forwardName, requestParams);

  • How to generate dynemic GET/SET Method in Struts.....

    hi,
    experts,
    i m doing struts application and i get struct at generatting GET/SET properties for my Dynemic html form in that form i fetch control name and related properties from database and i want to access this properties in action with the help of form which generates dynemic GET/SET properties depends on form controls
    how would i do please give some hints...
    example:
    my html form:
    <html:text name="bpmAttrForm" property="attrName"></html:text>
    . dynemic controls( i don't no how many )
    my form in struts
    public void getX()
    public void setX()
    .... dynemic GET/SET Properties ( i don't no how many )
    like this....
    thnks.....

    Hi ,
    You would have to create a Dynamic form class extending DynaActionForm and ovrride get and set method. In the implementation you access the dyanValues HashMap of DyanActionForm to set and get values from it.
    package yourpackage;
    import org.apache.struts.action.DynaActionForm;
    public class DynaForm extends DynaActionForm
      public Object get(String name)
          Object value = dynaValues.get(name);
          return (value);
      public void set(String name, Object value)
          dynaValues.put(name, value);
    }now in your struts configuration would be
    <form-bean name="myDynaForm" type="yourpackage.DynaForm" />
    if your action class execute method you would have to add and retrive your form properties through the map.
    DynaActionForm myDynaForm = (DynaActionForm) form;
    String prop1  = (String)myDyanaForm .get(propertyName);in your jsp you can access properties using expression library
    ${myDynaForm.map.propertyName}
    Cheers
    Masood

  • It is question on portlet pdk struts tags link

    hi:
    <td>
    <jsp:useBean id="rowEditSet" class="java.util.HashMap"/>
    <c:set target="${rowEditSet}" property="event" value="setCurrentRowWithKey"/>
    <c:set target="${rowEditSet}" property="Arg0" value="${Row.rowKeyStr}"/>
    <pdk-html:link action="/browseCustomers.do" name="rowEditSet">Select
    </pdk-html:link>
    result:
    Select
    dont use

    The problem was an old copy of the struts.jar file, which was missing the calculateUrl() method called by the Oracle tag. With a new struts.jar file, all was good.

  • Problem with Weblogic 8.1 Sp2 and Struts 1.1 + tiles

    I am using weblogic 8.1 sp2 with struts and tiles.
    I am getting the follwing error in my web pages, which is not consistent.
    The error stack trace is as below.
    [java] <Oct 6, 2005 12:23:53 PM GMT+05:30> <Error> <HTTP> <BEA-101309> <[ServletContext(id=3212
    195,name=awmweb,context-path=/awm)] could not deserialize the context attribute "org.apache.struts.
    iles.DEFINITIONS_FACTORY"
    [java] java.io.NotSerializableException: com.awm.awm.controllers.layout.BaseLayoutControll
    r
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
    [java] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
    [java] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
    [java] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    [java] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
    [java] at java.util.HashMap.writeObject(HashMap.java:978)
    [java] at sun.reflect.GeneratedMethodAccessor140.invoke(Unknown Source)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
    25)
    [java] at java.lang.reflect.Method.invoke(Method.java:324)
    [java] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:809)
    [java] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1296)
    [java] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    [java] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
    [java] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
    [java] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    [java] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
    [java] at java.util.HashMap.writeObject(HashMap.java:978)
    [java] at sun.reflect.GeneratedMethodAccessor140.invoke(Unknown Source)
    [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java
    25)
    [java] at java.lang.reflect.Method.invoke(Method.java:324)
    [java] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:809)
    [java] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1296)
    [java] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    [java] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
    [java] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
    [java] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    [java] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
    [java] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
    [java] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
    [java] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    [java] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
    [java] at weblogic.servlet.internal.AttributeWrapper.convertObjectToBytes(AttributeWrapper.
    ava:136)
    [java] at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:112)
    [java] at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:69)
    [java] at weblogic.servlet.internal.WebAppServletContext.getAttribute(WebAppServletContext.
    ava:619)
    [java] at org.apache.struts.tiles.TilesUtilStrutsModulesImpl.getDefinitionsFactory(TilesUti
    StrutsModulesImpl.java:145)
    [java] at org.apache.struts.tiles.TilesUtilStrutsModulesImpl.getDefinitionsFactory(TilesUti
    StrutsModulesImpl.java:133)
    [java] at org.apache.struts.tiles.TilesUtil.getDefinitionsFactory(TilesUtil.java:186)
    [java] at org.apache.struts.tiles.TilesUtil.getDefinition(TilesUtil.java:224)
    [java] at org.apache.struts.taglib.tiles.util.TagUtils.getComponentDefinition(TagUtils.java
    339)
    [java] at org.apache.struts.taglib.tiles.DefinitionTag.doStartTag(DefinitionTag.java:261)
    [java] at com.awm.awm.jsp._errors.__500_45_servererror._jspService(__500_45_servererro
    .java:208)
    [java] at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
    [java] at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStub
    mpl.java:971)
    [java] at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
    [java] at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:446)
    [java] at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at com.awm.awm.filters.AWMBaseFilter.doFilter(AWMBaseFilter.java:97)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at com.awm.awm.quote.QuoteUsageFilter.doFilter(QuoteUsageFilter.java:70)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at com.awm.awm.filters.AWMBaseFilter.doFilter(AWMBaseFilter.java:97)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at com.awm.awm.filters.FrontFilter.doFilter(FrontFilter.java:160)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at com.awm.awm.filters.JTidyFilter.doFilter(JTidyFilter.java:152)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at com.awm.awm.filters.PerfLogFilter.doFilter(PerfLogFilter.java:211)
    [java] at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    [java] at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.jav
    :305)
    [java] at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:
    23)
    [java] at weblogic.servlet.internal.WebAppServletContext.handleException(WebAppServletConte
    t.java:3908)
    [java] at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext
    java:3683)
    [java] at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585
    [java] at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    [java] at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    [java] >
    Can any one comment on why I am getting this error? Is it related to the hot deployment issue? Please comment.
    Thanks in advance,
    K

    Hi,
    Generally this type of exception raised by a class or the serialization runtime when a class may not be serialized.The argument should be the name of the class.
    You might be forgot to implement the serializable interface for the class in struts frame work.
    check it properly.
    Regards
    Anilkumar kari

  • Struts Portlet and interMedia

    Hi everyone,
    I'm building a struts app portlet.
    My portlet connects to a database schema, and in there I have a table with a column of ORDImage type.
    I've been using the PDK Struts taglib for the tags that are not supported by Portal.
    But I got to a point where I need to display the images I have in my database. Running the appllication outside Portal, I use the <adf:render> tag, which renders the images perfectly.
    Using the same tag running inside Portal, doesn't render the image.
    The <adf:render> tag renders a &lt;IMG src="..."&gt; tag. The reason why it works fine outside portal is understandable because the URL it puts in the src attribute is relative to the context-root of my app (I suppose).
    Inside portal, it renders the exact same &lt;IMG src="..."&gt; tag, but Portal doesn't understand the URL inside src.
    I have no idea if there is any PDK Struts tag that will do the trick, but I doubt it.
    I'm clueless on how to point Portal in the right direction.
    Any help, anyone ?
    Rui

    Hi,
    This may help. Use the pdk-struts-html:link tag instead.
    Something like
    <jsp:useBean id="prevDetail" class="java.util.HashMap"/>
    <c:set target="${prevDetail}" property="event_PreviousSet" value="PreviousSet"/>
    <c:set target="${prevDetail}" property="sortref" value="${param.sortref}"/>
    <c:set target="${prevDetail}" property="sortacc" value="${param.sortacc}"/>
    <c:set target="${prevDetail}" property="filteron" value="${param.filteron}"/>
    <pdk-struts-html:link action="portal/something.do" name="prevDetail">
    Good luck, Hernando

Maybe you are looking for

  • Error message withg sync, tried everything, nothing helped. Please help me.

    Gets error message "Attempting to copy to the disk "Ipod" failed. The disk could not be read from or written to". It will put on about 15-30 songs before displaying this message, and can fully sync but it takes forever because i have to press "ok" th

  • XML File to 3rd Party Provider w/o any Middleware

    Hi I have a requirement wherein we are required to send XML files to 3rd Party Supply chain provided w/o using any middleware in most secured form. The Customer is on ECC5. One of options i could think about is as mentioned below. -  file based and u

  • I'm getting ticked off!

    I have spent all afternoon/early evening trying in vain to get iTunes 7 to play a song. No luck. Apparently Apple has released a Beta version because that's what it's acting like. I can't even play internet radio stations. Of course, videos play on i

  • Intermittent high ping issues

    I've been having occasional high ping issues for quite a while now. They come and go at irregular times, and I'm not sure how to resolve this. Other computers on the network are showing similar latency. A traceroute to google's public DNS: Traceroute

  • Launching iDVD from iMovie

    After completing my movie in iMovie I click on iDVD and then create iDVD project. iDVD launches but my movie does not come up. Nothing comes up. I've updated all software already. Any suggestions? Thanks, christine