struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Markert <dirk.mark...@dr-markert.de>
Subject Re[2]: Form bean is not stored in request
Date Mon, 07 Jul 2003 09:47:34 GMT
Hello Nadja,

  

***************************************************************


NS> Hello again,

NS> it is actually struts that seems to be expecting the form bean in the
NS> request, under name given in 'attribute' in the mapping for the action. At
NS> least, the log-file tells me that struts looks there for the form bean and
NS> creates a new one if it can't find it.

NS> Okay, here is the action mapping for this:

NS> <action
NS> attribute="suchen"
Do you need the above line for some good reason. If not, drop it.

NS> input="/index.jsp"
NS> name="suchen"
NS> path="/suchen"
NS> scope="request"
NS> type="de.zmnh.struts.action.SuchenAction" />

NS> And this is the form bean (I did not copy the imports btw):
NS> public class SuchenForm extends ActionForm {

NS>         // --------------------------------------------------------- Instance
NS> Variables
NS>         private org.apache.log4j.Logger log =
NS> org.apache.log4j.Logger.getLogger(this.getClass().getName());
        
NS>         private TreeMap fields;
NS>         private TreeMap params;
NS>         private Integer cnt;
NS>         private boolean archivAnzeigen;
NS>         private ArrayList auswahl;

NS>         // --------------------------------------------------------- Methods
        
NS>         public SuchenForm(){
NS>                 fields = new TreeMap();
NS>                 params = new TreeMap();
NS>                 cnt = new Integer(1);
NS>         }
        
NS>         /** 
NS>          * Method validate
NS>          * @param ActionMapping mapping
NS>          * @param HttpServletRequest request
NS>          * @return ActionErrors
NS>          */
NS>         public ActionErrors validate(
NS>                 ActionMapping mapping,
NS>                 HttpServletRequest request) {

NS>                 ActionErrors err = new ActionErrors();
                
NS>                 Integer temp = (Integer)request.getSession().getAttribute("cnt");
NS>                 if(temp!=null && (temp.intValue()>cnt.intValue())){
NS>                         cnt=temp;
NS>                 }
NS>                 if(request.getParameter("mehr")!=null){
NS>                         LoggerSupport.logDebug("Counter: "+cnt.intValue(),log);
NS>                         LoggerSupport.logDebug("Mehr Felder Button gedrückt",log);
NS>                         cnt = new Integer(cnt.intValue()+1);
NS>                         LoggerSupport.logDebug("Counter: "+cnt.intValue(),log);
                        
NS>                 }else if(request.getParameter("weniger")!=null){
NS>                         LoggerSupport.logDebug("Counter: "+cnt.intValue(),log);
NS>                         LoggerSupport.logDebug("weniger Felder Button gedrückt",log);
NS>                         LoggerSupport.logDebug("Counter: "+cnt.intValue(),log);
NS>                 }       
NS>                 return err;
NS>         }

NS>         /** 
NS>          * Method reset
NS>          * @param ActionMapping mapping
NS>          * @param HttpServletRequest request
NS>          */
NS>         public void reset(ActionMapping mapping, HttpServletRequest request) {
NS>                 this.archivAnzeigen=false;
NS>         }

NS>         /**
NS>          * Returns the field.
NS>          * @return String
NS>          */
NS>         public Object getField(String key) {
NS>                 if(fields == null)
NS>                         return "";
NS>                 else if(fields.get(key)==null)
NS>                         return "";
NS>                 return this.fields.get(key);
NS>         }
        
NS>         public void setField(String key, String value){
NS>                 this.fields.put(key,value);
NS>         }

NS>         /**
NS>          * Returns the fields.
NS>          * @return String[]
NS>          */
NS>         public TreeMap getFields() {
NS>                 return fields;
NS>         }

NS>         /**
NS>          * Returns the parameter.
NS>          * @return String
NS>          */
NS>         public Object getParameter(String key) {
NS>                 if(params == null)
NS>                         return "";
NS>                 else if(params.get(key)==null)
NS>                         return "";
NS>                 return this.params.get(key);
NS>         }
        
NS>         public void setParameter(String key, String value){
NS>                 this.params.put(key,value);
NS>         }

NS>         /**
NS>          * Returns the params.
NS>          * @return String[]
NS>          */
NS>         public TreeMap getParams() {
NS>                 return params;
NS>         }

NS>         /**
NS>          * Sets the parameter.
NS>          * @param parameter The parameter to set
NS>          */


NS>         /**
NS>          * Returns the cnt.
NS>          * @return int
NS>          */
NS>         public Integer getCnt() {
NS>                 return cnt;
NS>         }
        
NS>         /**
NS>          * Feldauswahl
NS>          */
NS>         public Collection getSearchFields(){
NS>                 if(auswahl==null){
NS>                         auswahl = new ArrayList();
NS>                         Properties search = new Properties();
NS>                         try{
NS>                                 FileInputStream in = new
NS> FileInputStream(InventarKonfiguration.getHandle().getInvpropPath());
NS>                                 search.load(in);
NS>                         }catch(Exception e){
NS>                         LoggerSupport.logFatal(e,log);
NS>                 }
NS>                 int i=1;
NS>                 String temp;
NS>                 while((temp=search.getProperty("search"+i))!=null){
NS>                         LoggerSupport.logDebug("Nächstes Element für SearchFields
Coll.:
NS> "+temp,log);
NS>                         SearchOption temp2=new SearchOption(temp,
NS> search.getProperty("value"+i));
NS>                         auswahl.add(temp2);
NS>                         i++;
NS>                 }
NS>                 }
NS>                 return auswahl;
NS>         }

NS>         /**
NS>          * Returns the archivAnzeigen.
NS>          * @return boolean
NS>          */
NS>         public boolean isArchivAnzeigen() {
NS>                 return archivAnzeigen;
NS>         }

NS>         /**
NS>          * Sets the archivAnzeigen.
NS>          * @param archivAnzeigen The archivAnzeigen to set
NS>          */
NS>         public void setArchivAnzeigen(boolean archivAnzeigen) {
NS>                 this.archivAnzeigen = archivAnzeigen;
NS>         }

NS> }

NS> Thanks for the help.

NS> Greetings,
NS> Nadja

NS> ---------------------------------------------------------------------
NS> Nadja  Senoucci
NS> Universitaet Hamburg
NS> Zentrum für Molekulare Neurobiologie
NS> Service-Gruppe EDV
NS> Falkenried 94
NS> 20251 Hamburg
NS> Germany
NS> Tel.:040 - 428 - 03 - 6619
NS> Fax.:040 - 428 - 03 - 6621


NS> ---------------------------------------------------------------------
NS> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
NS> For additional commands, e-mail: struts-user-help@jakarta.apache.org



Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message