Heh, hey.  Substitute "sight" for "site".
in the first sentence of the below letter.
Too much time spent on web development for
me, don't you think?

-David "right sound, wrong spelling" Friedman

-----Original Message-----
From: David G. Friedman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 30, 2004 6:29 PM
To: Struts Users Mailing List
Subject: RE: Tiles and Forms


Grasshopper! The solution is in plain site in the userGuide for the HTML
Taglib.

Use the name="someBeanName" attribute available to many html:taglib fields.
Hopefully, you are using a version of Struts which is recent enough to
support that attribute (should be supported in 1.0, definitely in 1.1 and
up).

In my test, one of the JSP's used the html:form tag with an action.  A JSP
INSERTED into that tile had 2 lines:

<[EMAIL PROTECTED] uri="struts-html" prefix="html" %>
<html:text name="ActionFormTest" property="hair" />

<!-- I'm bald, understand the Hair reference? -->

All attributes from all beans (I put them all in scope at each previous
setup Action) showed up in the correct parts of the correct tile pieces.

If you need to start changing the form's submit action depending on which
button in which tile was touched, email me off-list (i.e. directly) and I'll
show you how to use document.getElementById(...) in JavaScript to change the
form's submit location/path/action/URL.

Regards,
David "Try that Tile question out!" Friedman

-----Original Message-----
From: Graeme Miller [mailto:[EMAIL PROTECTED]
Sent: Monday, November 29, 2004 9:16 PM
To: [EMAIL PROTECTED]
Subject: Tiles and Forms


What is the correct pattern for placing a struts html:form tag in a
layout where
- the controls may be in a different location (and hence different
tiles) from the buttons that submit the form
- where you want the action the form submits to to be customisable by
whatever jsp uses this form?

If anyone could give a simple example of using this pattern I would
appreciate it.

For example here's a simplification of what I am currently trying

Simple Layout

<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html";
prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles";
prefix="tiles"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean";
prefix="bean"%>
<html:html locale="true">
  <head>
    <title><tiles:getAsString name="title"/></title>
  </head>
  <body>
    <bean:define id="formAction"
type="java.lang.String"><tiles:getAsString
name="formAction"/></bean:define>
    <html:form action="<%= formAction %>">
    <tiles:insert attribute="body"/>
    <tiles:insert attribute="buttons"/>
    </html:form>
  </body>
</html:html>

Simple Use of the above layout (using the body wrap pattern for ease of
readability)

<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles";
prefix="tiles"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html";
prefix="html"%>
<tiles:insert page="simple-layout.jsp" flush="true">
  <tiles:put name="title" value="Hello World" />
  <tiles:put name="formAction" value="/SomeAction.do" />
  <tiles:put name="body" type="string"><html:checkbox
property="delete"></tiles:put>
  <tiles:put name="buttons" type="string"><html:submit
property="command">Save</html:submit></tiles:put>
</tiles:insert>

Unfortunately while the form action gets correctly rendered with the
right action passed from the jsp that uses the layout, the checkbox
rendering fails with the message "Cannot find bean
org.apache.struts.taglib.html.BEAN in any scope".  As far as I
understand this means the html form tag is not being put in scope for
the checkbox to find.

Any wise words appreciated.

Graeme

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to