Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why+beans+are+used?

 
anand kumarblr
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
we all are using beans in our struts application,but i want to know what are beans and what is the exact use of beans?A real time example for this?whether struts applications will not work without beans?briefly i want the use of struts in non programming words.
kindly post me fast
Thanks in Advance
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amith,
"Beans" is a very generic term. But used with Struts, beans generally refers to the ActionForm. Without "this bean(ActionForm)" it is not posible to use Struts as Struts framework calls this 'Bean' from the ActionClass.
Beans are otherwise POJOs that may be used anywhere in any application.
Hope it helps you.
 
anand kumarblr
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Roshini,
Thanks for the confirmation regarding beans,but i am new to struts so i want to know the difference between <bean:write> and <bean:message>?i know <bean:write> is used to get message from application properties file but where we use <bean:write>.what is the need?plese explain me with a sample example>
Anyway Thanks in Advance,you know more on struts,how many years of experience you have?if not mind.
bye ,be posting me,
AMITH
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know <bean:write> is used to get message from application properties file but where we use <bean:write>.what is the need?

Hi Amith,
Please note <bean:message> is used for wrtitng from the application properties file. But <bean:write> is used in conjunction with <logic resent>, <logic:iterate> to write on a JSP from a collection that is in ActionForm.
Example:<bean:message>
---------------
<bean:message key="label.search.name"/>:
<html:text property="fname"/>

this is same as:
Name:
<html:text property="fname"/>

Application Properties file
label.search.name=Name
--------------------------------
<bean:write>

<logic:iterate id="anyname" name="searchForm" property="results">
<tr>
<td><bean:write name="anyname" property="name"/></td>
<td><bean:write name="anyname" property="ssNum"/></td>
</tr>
</logic:iterate>

the ActionForm would have a collection as:

public void setResults(List results) {
this.results = results;
}

Thus it is used to write the dynamic values on the JSP..
Hope it helps..
[ November 06, 2006: Message edited by: RoshaniG Gopal ]
 
anand kumarblr
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roshani,
it helped me a lot.i am doing a sample application and my manager wants me to write action messages in my apllication,so please tell me what are action messages and where should i write these messages?how it displays?if possible explain this with an simple example?where it will display the messages?i think its a long question,sorry but i want to explain you all the queries.
I know you will solve my problem,Thanks in advance.
Bye and GoodMorninig.
 
RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amith,
It would be unfair to do spoon feeding as you would always feel uncomfortable in Struts. Please go through a basic struts tutorial and ask for specfic problem.
http://www.roseindia.net/struts/
Happy coding.
 
amith amith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok,let it be,thanks for giving me good suggestions,
i will post when there is a big problem,
Thanks,Amith
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic