• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically assigning class types in useBean tag  RSS feed

 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I want to assign dynamically class or Type in the UseBean tag.
Is it possible?

My code:

code 1 ---- is

<% long SubDeptCode = (Long.parseLong(request.getParameter("subDeptFk")));


if(SubDeptCode==1) {
%>
<jsp:useBean id="testForm" class="cal.xxxForm" scope="request"/>
<jsp:setProperty name="testForm" property="*"/>

<% } else if(SubDeptCode==2) {

%>
<jsp:useBean id="testForm" class="cal.yyyForm" scope="request"/>
<jsp:setProperty name="testForm" property="*"/>

or else if i can do like this
code 2:----
<jsp:useBean id="testForm" class=<%=varClassNmae%> scope="request"/>
<jsp:setProperty name="testForm" property="*"/>

Is This possible or if any alternate solution to dynamically assigning class type in JSP usebean tag.

Thanks
kundan
 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All no response what happened to my forum ppl.
plz do give some response
THanks
kundan
 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Peter Den Haan can throw some light on this.
THanks
kundan
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i haven't tried this. but as far as i know we cant do that. because compiler checks whether the class, which is defined inside the usebean tag, is there or not. and whether the type specified is really the type of class mentioned.

it wouldn't let you do. have you tried it out? try it out you will possibly get same kinda errors.

thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!