Solved

How JSP transform Struts tags using DOM ?

Posted on 2006-07-13
5
413 Views
Last Modified: 2013-11-19
When I use DOM in javascript to construct a Struts tag, per example:

var new_obj = document.createElement("input")
new_obj.type='text'                    
new_obj.name='formLigacoesMultiplasCamadaIFrame'
new_obj.property='nomeLigacao'
new_obj.styleClass='SubFormTextbox'
new_obj.maxlength='10'  
new_obj.disabled='false'
parent_obj.appendChild(new_obj)    

JSP transform this in the following tag:

<input disabled property=”nomeLigacao” styleClass=”SubFormTextbox” maxlength=”10”>

But when i construct the tag in HTML:

<html:text name="formLigacoesMultiplasCamadaIFrame" property="nomeLigacao" styleClass="SubFormTextbox" maxlength="10" disabled="false"/>

JSP transform this in the following tag:

<input class=SubFormTextbox disabled maxlength=10 value=teste name=nomeLigacao>

Note: in the last tag, “teste” is the value that I gave to “nomeLigacao” in my Stuts action

Could anyone tell why this happens? I need to obtain the same result through DOM or through HTML.

Thanks
0
Comment
Question by:NUNOPALMA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:dakyd
ID: 17101419
I'm not sure I understood your question, but if you're asking how to set the value of an input using the DOM, then you'd do it like this:

var new_obj = document.createElement("input");
new_obj.type='text';
new_obj.name='formLigacoesMultiplasCamadaIFrame';
new_obj.property='nomeLigacao';
new_obj.styleClass='SubFormTextbox';
new_obj.maxlength='10';
new_obj.disabled='false';
new_obj.value = 'teste';
parent_obj.appendChild(new_obj);

Hope that helps.
0
 

Author Comment

by:NUNOPALMA
ID: 17101620
No, it isn't exactly that. I want to set the value and the other attributes of an input using my Struts action and my CSS within DOM

0
 
LVL 19

Expert Comment

by:dakyd
ID: 17101805
Wait, so you want Struts to interact with the DOM?  I don't really use Struts, but from my understanding, that's done on the server-side, isn't it?  The DOM is on the client-side, so you can't make the two interact very easily.  What exactly are you trying to do?  If all you want is to modify the HTML on a given page, the DOM should be enough.  I guess I'm just not following what the desired result is, so I'm not sure what to suggest.

Also, I just noticed that I was setting the CSS class wrong.  Instead of this:
  new_obj.styleClass='SubFormTextbox';
you should use:
  new_obj.className='SubFormTextbox';
0
 

Author Comment

by:NUNOPALMA
ID: 17108485
I already solved my problem. I used innerHTML instead of DOM to construct the Struts tags. It works as i wanted: it uses the action that i defined.

Thanks dakyd
0
 
LVL 19

Accepted Solution

by:
dakyd earned 500 total points
ID: 17108768
Glad to hear it's working the way you want, although anything you can do with innerHTML should be possible with the DOM as well.  *shrug* So long as it works.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question