Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How JSP transform Struts tags using DOM ?

Posted on 2006-07-13
5
Medium Priority
?
416 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

636 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