Robert Burrell Donkin <[EMAIL PROTECTED]> writes:

>"Henning P. Schmiedehausen" wrote:

>> Hi,

>Hi Henning

>> in an application, I have the need to build "half" tags for e.g. a
>> <FORM> </FORM> tag. I want to have two methods, one which returns the
>> opening tag of an ECS object and one whith returns the closing tag.
>> (I need two callbacks from a velocity template to put opening /
>> closing tags in the right locations of a prebuilt form)

>i'm a bit confused.

>ecs is designed to create complete document fragments (eg. everything
>between the <FORM> and the </FORM> tags).

I know. What I have to do is this: 

In my application, the design is done (as it should be) by
designers. They use large table structures to place their
elements. And there now should be some forms inside which are my
responsibility. The basic layout looks like this (much stripped down,
hope the intention is still clear):

[... HTML header and top of page ...]

<FORM .... parameters ...>                                  
<INPUT TYPE="hidden" VALUE="$form.getValue("y1")" NAME="y1">
<INPUT TYPE="hidden" VALUE="$form.getValue("y2")" NAME="y2">
<INPUT TYPE="hidden" VALUE="$form.getValue("y3")" NAME="y3">
<INPUT TYPE="hidden" VALUE="$form.getValue("y4")" NAME="y4">

<TABLE>
<TR> <TD> .... </TD> </TR>
<TR> <TD> .... </TD> </TR>
<TR> <TD> .... </TD> </TR>
<TR> <TD> <INPUT TYPE="text" VALUE="$form.getValue("y5")" NAME="y5">  </TD> </TR>
<TR> <TD> <INPUT TYPE="text" VALUE="$form.getValue("y6")" NAME="y6">  </TD> </TR>
<TR> <TD> <INPUT TYPE="text" VALUE="$form.getValue("y7")" NAME="y7">  </TD> </TR>
<TR> <TD> .... </TD> </TR>

</TABLE>

</FORM>

[... rest of the page ... ]

I must have the form tags and fields. It is my job to get this
working, filling itself out from our application and so on. It is
their job to make it "look nice".

The designers are not able to place <FORM> and <INPUT> tags according
to specifications and get the " right. Yes, they're dumb but I'm stuck
with them (I do contract work for them, not the other way round =:-) )

And I've corrected complex and obfuscated HTML for some missing
"hidden" fields, missing " or wrong identifiers so often, that I'm
pretty much fed up.

So I basically wanted to do the following thing as a velocity
template, tell them "write HTML and use the following tags" :

[... HTML header and top of page ...]

$form.getStart()
<TABLE>
<TR> <TD> .... </TD> </TR>
<TR> <TD> .... </TD> </TR>
<TR> <TD> .... </TD> </TR>
<TR> <TD>$form.getInput("y5")</TD> </TR>
<TR> <TD>$form.getInput("y5")</TD> </TR>
<TR> <TD>$form.getInput("y6")</TD> </TR>
<TR> <TD> .... </TD> </TR>
</TABLE>
$form.getEnd()

[... rest of the page ... ]

Yes, they _can_ write this. 

So in my code, I have the following methods:

private org.apache.ecs.Form form = null;

private org.apache.ecs.Form getForm()
{
  if(form != null)
    return form;

  form = new org.apache.ecs.Form("action", "method")
              .addElement(new org.apache.ecs.Input(org.apache.ecs.Input.HIDDEN, "x1", 
"y1"))
              .addElement(new org.apache.ecs.Input(org.apache.ecs.Input.HIDDEN, "x2", 
"y2"))
             [...]

  return form;
}

public String getStart()
{
        return this.getForm().openingTag().toString();
}

public String getEnd()
{
        return this.getForm().closingTag().toString();
}

with "openingTag()" returning everything up to the "</FORM>" closing
tag and "closingTag()" just returning "</FORM>" (the closing tag of
the Form element).

I could also live, if "openingTag()" just returns the "<FORM>" without
the inner elements:

private org.apache.ecs.StringElement formContents = null;
private org.apache.ecs.Form form = null;

private org.apache.ecs.StringElement getFormContents()
{
  if(formContents != null)
    return formContents;

  formContents = new org.apache.ecs.StringElement()
                     .addElement(new org.apache.ecs.Input(org.apache.ecs.Input.HIDDEN, 
"x1", "y1"))
                     .addElement(new org.apache.ecs.Input(org.apache.ecs.Input.HIDDEN, 
"x2", "y2"))
             [...]

   return formContents;
}

private org.apache.ecs.Form getForm()
{
  if(form != null)
   return form;

  form = new org.apache.ecs.Form("action", "method");

  return form;
}


public String getStart()
{
        return this.getForm().openingTag().toString() + 
this.getFormContents().toString;
}

public String getEnd()
{
        return this.getForm().closingTag().toString();
}


At the moment, the getFormContents() is written as above but uses a
StringElement as the wrapper and the getStart() looks like this:

public String getStart()
{
  return "<FORM ACTION=\"action\" METHOD=\"method\">\n" + getFormContents().toString();
}

public String getEnd()
{
  return "</FORM>";
}

and I wanted to keep _all_ HTML tags out of strings but in ECS
elements. I hate HTML. =:-) I want a program to get all the gritty
stuff right. That's why I use ECS on java and CGI.pm on perl.


>so, everything that you want to end up in the form needs to be added as
>ecs elements to
>the Form element. if you construct it like this, then everything should
>always end up in the right places.

Yes, this is the world of completely java generated pages and everone
being a designer and a developer.  I have to work with people that
don't know anything outside their DreamWorld^WWeaver. They pay good,
however. 0:-)

        Regards
                Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     [EMAIL PROTECTED]

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   [EMAIL PROTECTED]
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

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

Reply via email to