• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tags & UseBean Tag  RSS feed

 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All!
Consider following jsp code
<test:TrnsDisplay>
<jsp:useBean id="TRANSACTION_BEAN" scope="request" class="amp.valueBeans.TrnsVBean"/>
<jsp:getProperty name="TRANSACTION_BEAN" property="TrnsDate">
</test:TrnsDisplay>
In Handler class (In doStartTag method)of Custom Tags i am creating bean of type TrnsVbean,setting Date property and storing it in a request scope.
But getproperty Tag is displaying nothing.
What may be the reason?
Any suggestions are appreciable.
TIA
Warm rgds
Manohar

 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, check that you are placing the bean into the request under the name of "TRANSACTION_BEAN".
How are you placing the bean into the request?
Cheers
Simon
p.s. you could always consider "introducing" a NESTED scripting variable into the page rather than placing the bean in the request scope alone. This will in turn negate the need for the <jsp:useBean/> tag inside your <test:TrnsDisplay> tag.
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Simon!
Thanks for the reply. Here is my code in Tag Handler.

try
{
TrnsVBean trnsVBean1=new TrnsVBean();
trnsVBean1.setTrnsDate("20010101");
trnsVBean1.setTrnsDescription("SHOPPING");
trnsVBean1.setTrnsAmount("100");
trnsVBean[0]=trnsVBean1;
if(count<noOfTransaction)
{
System.out.println("TrnsDisplayTagHandler-->doStartTag()-->TransDate "+trnsVBean[0].getTrnsDate());
(pageContext.getSession()).setAttribute("TRANSACTION_BEAN",trnsVBean[count++]);
}
}
catch(Exception e)
{
e.printStackTrace();
}
return EVAL_BODY_TAG;

This code is there in my doStartTag() metod.
BTW pls exaplain what is nested scripting variable.. Is it different from scriplets? I donn wann to use scriptlets in my page...
TIA
Rgds
Manohar
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha ... you're actually putting the bean into the session scope and not request.
Originally posted by Manohar Karamballi:
(pageContext.getSession()).setAttribute("TRANSACTION_BEAN",trnsVBean[count++]);
Manohar[/B]

Try switching this to pageContext.getRequest().....
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Simin!
I posted the code by mistake,,,, I tried to keep it in request but is of no use..Still my bean in JSP is not getting reference to the instance created in the handler,,,

Help me out..
Rgds
Manohar
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case, check that your count variable is what you think it is. You are printing out trnsVBean[0] but putting trnsVBean[count] into the request...
HTH
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Simon!
Count is zero at that step.. Pls see is there any blunder that i am doing there....

Rgds
Manohar
 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Simon!
In my JSP if i placed following scriptlet it is priniting to console properly..
<jsp:useBean id="TRANSACTION_BEAN" scope="request" class="amp.valueBeans.TrnsVBean"/>
<%System.out.println(".........."+TRANSACTION_BEAN.getTrnsDate());%>

Then why getProperty Tag is displaying nothing?
Rgds
Manohar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!