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

Dynamically setting property name in jsp:setProperty

 
anindya halder
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone...

I am trying to set property name of the bean dynamically in <jsp:setProperty> .

I found out that when a field value is empty,bean is not called implicitly by <jsp:setProperty name="someName" property="*" />.
Therefore I am trying to do it forcefully ......
As there are two many fields I dont want to do it individually and trying to do it dynamically like this........


<%

for(Enumeration e = request.getParameterNames(); e.hasMoreElements(); ){
String ParameterNames = (String)e.nextElement();

if (request.getParameter(ParameterNames).equals(""))
%>
<jsp:setProperty name="adetails" property = "<%= ParameterNames %>" value="" /> ;

<%
}
%>



But I am getting an error....
Cannot find any information on property '' in a bean of type 'tdcbeans.ApplicationDetails'

[adetails is the object of 'tdcbeans.ApplicationDetails' class.

Please help.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you really using that loop in your JSP ?
Why on earth would anyone want to set an empty property? This is different than an empty value for the property.
That is no way possible and not at all logical.
 
Sai Prasad Sabeson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think any problem will arise if the field is empty.It wil work anyways.
Things that will happed is that empty field's value will be null if its a string field or its default value is set (in case if its non string var).

 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sai Prasad Sabeson wrote:Things that will happed is that empty field's value will be null if its a string field or its default value is set (in case if its non string var).

No. If the code tries to assign a blank string, then the value wont be null for a string.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic