Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html: hidden problem

 
Kai Unewisse
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I have in the request type=user or module
I read the type-value with :
<bean arameter id="param1" name="type"/>

But how can I include this value into the value-attribute without using Java Code <% ..%> like :
<html:hidden property="type" value="<%=type%>"/>
When I say name="param1" inside this tag, it says there is no property type in bean type...

Any idea ?
Thanks a lot !!
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
It would help to see your code. Offhand, does your bean have getParam1/setParam1 methods? Is this a bean you have written or does it come from a third-party package?
 
Kai Unewisse
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
I don't use get/setParam1 Methods in my bean.
Then I would have the solution ....

http://localhost:8080/appointment.jsp?param1=user
I know that it works with :
<%String type = request.getAttribute("type"); %>
<html:hidden property="startDay" value="<%=type%>" />
But I don`t want use JSP pages which are XML conform...
Any thoughts John ?
Another problem would be, if you have a bean with get/setParam2 Method and you want say param1=param2 ?
This doesn`t work :
<html:hidden property="param1" name ="beaninstance" />
Struts would look for the method get/setParam1 in beaninstance, which is not available....
 
Ted Husted
Author
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, you should encapsulate whatever parameters your application uses in the ActionForm. So there would be a getParam1 and setParam1 property on the ActionForm related to this workflow.
Struts will then take care of populating the ActionForm from the request for you. This way you can deal with JavaBeans and pretty much ignore the request altogether.
Then in tags like html:hidden, you can just refer to property="param1".
An important design pattern to follow in Struts is to always link and submit to an action, never to a dynamic presentation page, like a JSP. This gives the controller a chance to populate any form associated with the request. In Struts 1.1, it also enables the module features.
HTH, Ted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic