Thank you everyone. The problem is solved.
Now i set the same attribute for both action.
<action path="/setUpCategoryEditForm"
type="com.strutsgen.garuda.SetUpCategoryEditAction"
name="categoryEditForm"
attribute="val_categoryEdit"
scope="request"
validate="false"
>
<forward
name="continue"
path="/categoryEditForm.jsp"/>
</action>
<action path="/categoryEdit"
type="com.strutsgen.garuda.CategoryEditAction"
name="categoryEditForm"
attribute="val_categoryEdit"
scope="request"
validate="true"
input="/categoryEditForm.jsp"
>
<forward
name="success"
path="/categoryEditOk.jsp"/>
</action>
My codes in SetUpCategoryEditAction:
CategoryEditForm categoryEditForm = (CategoryEditForm) form;
categoryEditForm.setName("testing");
request.setAttribute("categoryEditForm", form);
Dody.
>I'll be! Never used "attribute" either. Thanks.
>
>Jack
>
>
>On Wed, 12 Jan 2005 08:19:25 -0600, Joe Germuska <[EMAIL PROTECTED]> wrote:
>> The problem is that you are specifying the "attribute" value for one
>> of your action mappings, but not for the other. For the first (setup
>> action), because no "attribute" value is set in the ActionMapping,
>> Struts looks in the request for a bean under the form's name
>> "categoryEditForm". If it doesn't find one, it creates one and puts
>> it there, so that by the time your Action's execute method is called,
>> the ActionForm passed in the signature is also in the request under
>> that attribute name.
>>
>> Then, when the JSP renders, the html:form tag uses its action
>> attribute to look up the ActionMapping for the submission
>> ("/categoryEdit"). This ActionMapping specifies that its form bean
>> should be stored under the attribute name "val_categoryEdit". There
>> is nothing in the request under that name, so Struts creates a new
>> form, which is not initialized, and uses it for prepopulating form
>> field values.
>>
>> Again, if you do not specify an "attribute" in an <action> element,
>> the value defaults to the form's name (as specified in the <action>'s
>> "name" attribute). I have never had a reason to specify "attribute"
>> in the <action> element, but if you do, you need it to be consistent
>> between the actions that are cooperating.
>>
>> Hope this helps,
>> Joe
>>
>>
>> At 4:19 PM +0700 1/12/05, Dody Rachmat Wicaksono wrote:
>> >I'm trying to create an edit page. I think I already in the right
>> >direction, but still unable to populate data even with a direct
>> >value via action class. Please let me what's wrong here. I've spend
>> >3 days alone with this problem.
>> >Thank you.
>> >
>> >
>> >I created two action file:
>> >- SetUpCategoryEditAction.java (this action will populate data from
>> >db to form)
>> >- CategoryEditAction.java (this action will save the data)
>> >
>> >My formbean: CategoryEditForm.java
>> >----------------------
>> >public class CategoryEditForm extends ValidatorForm {
>> > private String name;
>> > private String categoryId;
>> >
>> > public void setName(String s) {
>> > this.name = s;
>> > }
>> > public String getName() {
>> > return name;
>> > }
>> > public void setcategoryId(String s) {
>> > this.categoryId = s;
>> > }
>> > public String getcategoryId() {
>> > return categoryId;
>> > }
>> >}
>> >
>> >
>> >My struts-config.xml
>> >----------------------
>> ><form-bean name="categoryEditForm"
>> >type="com.strutsgen.garuda.CategoryEditForm"/>
>> >
>> > <action path="/setUpCategoryEditForm"
>> > type="com.strutsgen.garuda.SetUpCategoryEditAction"
>> > name="categoryEditForm"
>> > scope="request"
>> > validate="false"
>> > >
>> > <forward
>> > name="continue"
>> > path="/categoryEditForm.jsp"/>
>> > </action>
>> >
>> > <action path="/categoryEdit"
>> > type="com.strutsgen.garuda.CategoryEditAction"
>> > name="categoryEditForm"
>> > attribute="val_categoryEdit"
>> > scope="request"
>> > validate="true"
>> > input="/categoryEditForm.jsp"
>> > >
>> > <forward
>> > name="success"
>> > path="/categoryEditOk.jsp"/>
>> > </action>
>> >
>> >
>> >SetUpCategoryEditAction.java:
>> >----------------------
>> >public final class SetUpCategoryEditAction extends Action {
>> >
>> > public ActionForward execute(ActionMapping mapping,
>> > ActionForm form,
>> > HttpServletRequest request,
>> > HttpServletResponse response)
>> > throws Exception {
>> >
>> > CategoryEditForm categoryEditForm = (CategoryEditForm)form;
>> > categoryEditForm.setName("testing");
>> >
>> > return (mapping.findForward("continue"));
>> > }
>> >}
>> >
>> >
>> >
>> >---------------------------------------------------------------------
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>>
>> --
>> Joe Germuska
>> [EMAIL PROTECTED]
>> http://blog.germuska.com
>> "Narrow minds are weapons made for mass destruction" -The Ex
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
>--
>------------------------------
>
>"You can lead a horse to water but you cannot make it float on its back."
>
>~Dakota Jack~
>
>"You can't wake a person who is pretending to be asleep."
>
>~Native Proverb~
>
>"Each man is good in His sight. It is not necessary for eagles to be crows."
>
>~Hunkesni (Sitting Bull), Hunkpapa Sioux~
>
>-----------------------------------------------
>
>"This message may contain confidential and/or privileged information.
>If you are not the addressee or authorized to receive this for the
>addressee, you must not use, copy, disclose, or take any action based
>on this message or any information herein. If you have received this
>message in error, please advise the sender immediately by reply e-mail
>and delete this message. Thank you for your cooperation."
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
= = = = = = = = = = = = = = = = = = = =
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]