Nothing special. Just pick up your form bean from the scope and use the jsp:useBean tag plus JSP expression, say like that:

 <jsp:useBean id="customer" beanName="customerForm" class="CustomerForm"/>
   and
  <%=customer.customerName%>

You just need to know where your bean is placed by the framework.
Usually you can find it in the request or session scope under the atribute stored with the key that matches the name of you bean in struts-config.xml file.


for example,

If you had:
<form-bean name="customerForm" type="com.bean.CustomerForm"/>
You could retreive the bean using
 <jsp:useBean id="customer" beanName="customerForm" class="CustomerForm"/>

Generally speaking you could put all your beans under the same key. You just specify the value of the attribute atribute of you action in struts-config:

<action path="/edit-customer"
   type="com.action.EditAction"
  name="CustomerForm"
  attribute="com.constants.Glogal.KEY_FORM_BEAN"
  >
</action>

Moreover, you can create constant:
Global
{
 String KEY_FORM_BEAN = "com.constants.Glogal.KEY_FORM_BEAN";
}
and use it everyvery in your code.

Say, <jsp:useBean id="customer" beanName="<%=Global.KEY_FORM_BEAN %>" class="CustomerForm"/>

Thus you do not need to know on the page names of the form beans in struts-config.

Rgards,

-Viktar


----- Original Message ----- From: "nitin dubey" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Friday, March 11, 2005 11:48 AM
Subject: Re: using Taglibs



Thanks Viktar,

I am planning to use DispatchAction with which we can
use unspecified() method to populate the ActionForm
properties.  But how to put these properties in JSP
controls ?

Regards,

Nitin

--- Viktar Duzh <[EMAIL PROTECTED]> wrote:
Jack,

I suppose you are not right. There is no problem of
using ordinary <form>
HTML tag in a plain JSP. But that form must have a
correct url and names of
the input elements within the page to make the
framework pick up right
action and populate form bean respectively.

I will give a example.

1. Suppose you have the following in your config
file:

        <action path="/save-customer"
                type="com.action.SaveAction"
                name="CustomerForm">
            <forward name="sucess"
path="/SavePage.jsp"/>
        </action>

2. Your Customer.jsp would be:
...
<form action="save-customer.do">
    <input type="text" name="customerName" ... />
    <input type="submit" ... />
</form>

3. Your CustomerForm is expected to have the
customerName property.

Thus, when a user click on the submit button the
request comes in and the
struts tries to find an action with "save-customer"
path. Having found it,
it instantiates the CustomerForm object and then
tries to populate the
properties of the bean based on HTT request
parameters (customerName here).
In the end, your class action class has acess to the
parameters submitted by
the ordinary HTML form.

But here is one thing. Customer.jsp usually shows
some data. So a deveoper
should manually set the value of the form's fields.
I means it should get a
bean that holds the customer data and set the value
of the customerName
field by some other tag.

To make clear why some people are trying to do it.
An application would be
built on the struts framework plus jstl tags. Using
the jstls tags is taken
because struts html tags might not cover some
attributes of some html
elements.

Regards,

-- Viktar

----- Original Message ----- From: "Dakota Jack" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List"
<user@struts.apache.org>
Sent: Friday, March 11, 2005 9:56 AM
Subject: Re: using Taglibs



> You need to use <html:form>, so the answer is that you have to use the > taglibs unless you do some serious coding changes to the framework. > Why do you want to use the form but not the taglibs? If you just want > to do that, build your own ActionForm with your own autopopulation > classes, etc.? > > What you are trying to do or why is not clear. > > Sounds like you are a bit unacquainted with Struts and I would > recommend that you take a closer look before deciding what you want to > do. > > Jack > > > On Thu, 10 Mar 2005 23:46:40 -0800 (PST), nitin dubey > <[EMAIL PROTECTED]> wrote: >> Hello, >> >> Can we use struts without using its taglibs ? We will >> just write plain JSPs. If yes how do we get the >> values into and from our ActionForms ? >> >> regards, >> >> Nitin >> >> __________________________________ >> Do you Yahoo!? >> Yahoo! Small Business - Try our new resources site! >> http://smallbusiness.yahoo.com/resources/ >> >>

---------------------------------------------------------------------
>> 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~
>
>


---------------------------------------------------------------------
> 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]





__________________________________ Do you Yahoo!? Make Yahoo! your home page http://www.yahoo.com/r/hs

---------------------------------------------------------------------
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]



Reply via email to