File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes html: hidden problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html: hidden problem" Watch "html: hidden problem" New topic

html: hidden problem

Kai Unewisse

Joined: Nov 10, 2002
Posts: 10
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

Joined: Apr 05, 2000
Posts: 1449
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?

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Kai Unewisse

Joined: Nov 10, 2002
Posts: 10
Hi John,
I don't use get/setParam1 Methods in my bean.
Then I would have the solution ....

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
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
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.

<a href="" target="_blank" rel="nofollow">Struts in Action</a>
I agree. Here's the link:
subject: html: hidden problem
It's not a secret anymore!