• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Action Form Problem

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Thanks for your continuous help for my questions.

I have another problem,
I have a form bean in session scope, While populating the form bean i am not taking from object from the execute method parameter. I am initializing myself in the progam becuase the form bean is in session scope.

My problem is if i initialize the form in the display action and populate it. All the variables in the form are not null, but i am not null pointer exception at the jsp saying that the same variable is null.

Thanks Any advance,
Any suggestions are welcome
Srilakshmi
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am Chinese,so My English ability is not good,but I think I know your problem.
I think that maybe variables in your formbean and your parameter in form in JSP are not matching. Induce variables in your formbean is null.please check your JSP and formbean.
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my Display Action if i get form object from method parameter 'form', Then i am not getting null pointer exception.

If i get like that every time that form is displaying first retrieved values instead of taking dynamically passed values.

I dont know what is the problem here.

Help me
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
help me :-(
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose the submitting action for that page does not use the same ActionForm as your Setup (or as you called it, Display) Action.

If I am not correct, please post your Setup Action's execute method, your <html:form> tag from the jsp, and your ActionMapping from struts-config that matches the action attribute from the html:form tag.
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

My Display Action Java is


import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class DisplayTrans extends Action {

int index = -1;
ArrayList callList = null;
TransForm transForm = null;
HttpSession session;
public DisplayTrans() {
}

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest req,HttpServletResponse res)
throws Exception {
int index = -1;
session = req.getSession();
transForm = (TransForm)form;
// Doing all the code for populating transForm
form = (ActionForm)transForm;
TransForm tran = (TransForm)form;
System.out.println("From DISPLAY TRANS ==== "+tran.getParamedicIds());
// The above system out is retrieving values from the getter method
return mapping.findForward("success");
}
}

struts-config action mapping entry is

<form-bean name="transForm" type="org.xxxx.cts.actionforms.TransForm"/>

<action path="/DisplayTrans"
type="org.xxxx.cts.actions.DisplayTrans"
name="transForm"
scope="session" validate="false">
<forward name="success" path="/jsp/TRANS.jsp" />
</action>

HTML Form is

<html:form action="/SubmitTrans.do">
<html:select name="transForm" property="paramedicName" size="1">
<html ptions name="transForm" property="paramedicIds" labelName="transForm" labelProperty="paramedicNames"/>
</html:select>
</html:form>
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your action-mapping PATH and <html:form action--both are not same in ur application...
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i has another mapping to submit the form called submitTrans.do
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I asked for the ActionMapping of the submitting Action.

First, get rid of the instance variables in your Action class. Never, ever, ever use instance variables in an Action class.

There is a bunch of unnecessary casting in the Action as well.
form = (ActionForm)transForm;
TransForm tran = (TransForm)form;
There's no need for that.

What exactly is the error again? - copy/paste is good for communicating that.
Also, I recommend using html ptionsCollection over html ptions.
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the correction marc!!!


What is my problem is i am not able to display a jsp with dynamic values with an action form which is in session scope.

The scenario is i have list and am calling same .do for the rows in the list

If i retrieve the jsp first time with a record, for all the rest of the records the jsp is displaying with the same first record values.
That means the action form bean is not refreshing for every jsp or DisplayAction.do call
I want to refresh the form bean for every DisplayAction.do for that i changed the DisplayAction and instantiated my form bean instead of taking it from the execute method parameter Then i am getting the following exception.

It worked perfect if i put the formbean scope to session
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am sorry for the mistake!!

The last line it worked good with request scope
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two required mappings for the problem

<action path="/SubmitTrans"
type="org.fdny.cts.actions.SubmitTrans"
name="transForm"
scope="session"
validate="true"
input="/FailedTrans.do">
<forward name="success" path="/html/CloseWindow.htm"/>
<forward name="failure" path="/DisplayTrans.do"/>
</action>
<action path="/FailedTrans"
type="org.fdny.cts.actions.FailedTrans"
name="transForm"
scope="session" validate="false">
<forward name="success" path="/jsp/TRANS.jsp" />
</action>
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Srilakshmi Vara:
Two required mappings for the problem

<action path="/SubmitTrans"
type="org.xxxxx.cts.actions.SubmitTrans"
name="transForm"
scope="session"
validate="true"
input="/FailedTrans.do">
<forward name="success" path="/html/CloseWindow.htm"/>
<forward name="failure" path="/DisplayTrans.do"/>
</action>
<action path="/FailedTrans"
type="org.xxxxx.cts.actions.FailedTrans"
name="transForm"
scope="session" validate="false">
<forward name="success" path="/jsp/TRANS.jsp" />
</action>



Why have FailedTrans? Doesn't it make sense to make the input value for SubmitTrans be the same as the failure forward (DisplayTrans.do)?

What is my problem is i am not able to display a jsp with dynamic values with an action form which is in session scope.
What does "not able to display" LOOK like? If you get a message, please copy it here. If you get a completely blank screen, please say so.
 
This tiny ad is guaranteed to be gluten free.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic