Hi everyone,
I have a situation in which I would like to do the following:
1) I'm at a jsp page, let's call it "a.jsp". It has one link that looks
like:
<html:link page="/mainMenu.do?action=customer"> Customer
</html:link>
2) My mainMenu action in struts-config.xml looks like (name="..." is
left out on purpose):
<actionpath="/mainMenu"
type="net.alfa.china.menus.MainMenuAction">
<forward name="customer" path="/customer_main.jsp"/>
<forward name="order" path="/order_main.jsp"/>
<forward name="purchase" path="/purchase_main.jsp" />
<forward name="inventory" path="/inventory_main.jsp" />
</action>
3) Inside of perform in MainMenuAction, I would like to create my own
form bean of type ActionForm. I am then going to load a customer from
my db (through a business logic bean), and set the fields in the
ActionForm. I'm hoping to use that ActionForm to populate a form in
"customer_main.jsp" when we finally forward there. That form is defined
using <html:form>.
I'm basically wondering what the mechanism is that struts uses to
populate a <html:form> with an ActionForm. I'm coming from a page
without a form (a.jsp), would like to be able to create an ActionForm in
perform(), stick it in the request, and when I forward to my
customer_main.jsp, have struts populate the form there with what's in
the ActionForm.
What you've done sounds ok to me.
Maybe you forget to associate the <html:form> in your customer_main.jsp with a formBean? If, let say, it is assoicated with a formBean called 'customerInfo', in your MainMenuAction, you do:
request.setAttribute("customerInfo", customerInfoObj);
Struts should populate the form for you.
One more thing is, Struts can only populate <html:*> fields, not 'native' html <input>.
I've tried quite a few different approaches and can't seem to make it
work. Is this possible? Any suggestions?
Thanks,
Tony Li
John Yu Scioworks Technologies
e: [EMAIL PROTECTED] w: +(65) 873 5989
w: http://www.scioworks.com m: +(65) 9782 9610
Scioworks Camino - "Rapid WebApp Assembly for Struts"