The things on the client happen on the client.  The things on the server happen on
the server.

What I do to handle this is read a template file (a piece of HTML), and plug in
things replacing some text tags.  (HIDDEN_FIELD_VALUE_GOES_HERE), etc...  This
gives you full control of everything.  Porblems with this method include naming
conflicts, passing the form name that the tag appears on into the tag, restoring
the state of the HTML controls that control the HTML rendered by the tag (checkbox
states, default selection list, rows selected in a table), etc.

This is hideous.  Hideous.  It's just better than any alternatives I've seen.

Also, the fact you have javascript variables, request variables and tag variables
laying arround makes it even more unpleasent.

-G

P.S. Don't tell me my code needs to use StringBuffer and not String.  This is from
a rapid prototype and not production code.  The method could be improved.  Usage
ex for a tag, follows this method.

 /** Takes a string, and replaces the replace text with new text.
   * @param  str     String to replace into
   * @param  replace Text ro replace.
   * @param  newtext What to replace it with.
   * @return str with the replace text replaced with the new text.
   */
protected static String replaceTextInMiddleOfStringIfItExists(String str,
                                                        String replace,
                                                        String newtext){

      //Might be more than one, replace 'em all.
      while(str.indexOf(replace)!=-1){
         str = str.substring(0,str.indexOf(replace)) +
               newtext +
               str.substring(str.indexOf(replace)+replace.length());
      }
      return str;
   }


Usage EX:
...
      try {
         JspWriter wr = pageContext.getOut();
         PrintWriter writer = new PrintWriter(wr);
         BufferedReader br = new BufferedReader(new
FileReader("/home/gbishop/www/bmg/dev/run/ckie/jsp/charttabletag.template"));

         String line;

         while( ((line=br.readLine())!=null)){
            line = replaceTextInMiddleOfStringIfItExists(line,
"HEADER_GOES_HERE",               header );
            line = replaceTextInMiddleOfStringIfItExists(line,
"TABLE_CONTENTS_GOES_HERE",       tableContents );
            line = replaceTextInMiddleOfStringIfItExists(line,
"SELECTIONS_GOES_HERE",
pageContext.getRequest().getParameter("TableSelections") );
            line = replaceTextInMiddleOfStringIfItExists(line,
"BACKGROUND_COLOR_GOES_HERE",     backgroundColor );
            line = replaceTextInMiddleOfStringIfItExists(line,
"HILIGHTED_COLOR_GOES_HERE",      hilightedColor );
            line = replaceTextInMiddleOfStringIfItExists(line,
"DRAG_COLOR_GOES_HERE",           dragColor );
            line = replaceTextInMiddleOfStringIfItExists(line,
"SELECTED_COLOR_GOES_HERE",       selectedColor );
            line = replaceTextInMiddleOfStringIfItExists(line,
"BORDER_COLOR_GOES_HERE",         borderColor );
            line = replaceTextInMiddleOfStringIfItExists(line,
"TABLE_DATA_VIEW_NAME_GOES_HERE", tableDataViewHiddenFieldName );
            line = replaceTextInMiddleOfStringIfItExists(line,
"HTCS_TO_INVOKE_GOES_HERE",       htcs );
            writer.println(line);
         }
      } catch(IOException e) {
            throw new JspTagException("IO Error: " + e.getMessage());
      }
      return SKIP_BODY;

[EMAIL PROTECTED] wrote:

> Hi Taglib Team,
>
> is there any Taglib that wraps some JavaScript Functions. I'm not meaning
> the ActionListeners but following Funktions may be sometimes usefull.
>
> For example:
>
> - something to count an access frames like parent.frames[#]
> - something like the Screen Object in JS might be usefull ( I use
> java.awt.Toolkit.getDefault().getDimension() to get the acess similar
> attributes)
>
> What do you think about this?
> Is something like that usefull?
>
> Thx for response & feedback.
>
> Tobias
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Attachment: charttabletag.template
Description: application/unknown-content-type-template_auto_file

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

Reply via email to