You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Newton <ne...@yahoo.com> on 2007/06/28 15:57:48 UTC

Re: [S2] Master-Detail Form

From: Luciano Costa <mo...@gmail.com>
> I have the "Poll" and "PollOption" objects. In my 
> form, I want to be able to add more options to 
> my Poll via javascript code.

You didn't include the JavaScript you're using to create the new form elements, so it's kinda hard to say.

d.





 
____________________________________________________________________________________
Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RES: [S2] Master-Detail Form

Posted by Luciano Costa <mo...@gmail.com>.
Sure!

function addPollOption(){
	var tr, td, rowId;
	tbody = document.getElementById('tableBodyAddPollOptions');
	rowId = tbody.rows.length;	
	tr = tbody.insertRow(rowId);	
	td = tr.insertCell(tr.cells.length);
	td.innerHTML  = " <input type='hidden'
name='pollOptions["+rowId+"].id' class='ShortInput'>";
	td.innerHTML += " <input type='text'
name='pollOptions["+rowId+"].option' value='' class='LargeInput'
style='width:400px'>";
	td.setAttribute("valign", "top");
}


thanks,

Luciano Costa


-----Mensagem original-----
De: Dave Newton [mailto:newton.dave@yahoo.com] 
Enviada em: quinta-feira, 28 de junho de 2007 06:58
Para: Struts Users Mailing List
Assunto: Re: [S2] Master-Detail Form

From: Luciano Costa <mo...@gmail.com>
> I have the "Poll" and "PollOption" objects. In my 
> form, I want to be able to add more options to 
> my Poll via javascript code.

You didn't include the JavaScript you're using to create the new form
elements, so it's kinda hard to say.

d.

----------------------------------------------------------------------------
------------------------------------------------

De: Luciano Costa [mailto:luciano@monttez.com] 
Enviada em: quarta-feira, 27 de junho de 2007 12:51
Para: 'user@struts.apache.org'
Assunto: [S2] Master-Detail Form 

Hi!

I have the "Poll" and "PollOption" objects. In my form, I want to be able to
add more options to my Poll via javascript code.

The problem is I don't know how to put the fields in my form. The way I try
is not binding the form data with Action properties (a "public Poll poll;"
with getter and setter).

My PollAction.poll.pollOptions is null after form submission.

Can you help me?


Sample code I trying:

Poll {
  Integer id;
  String question;
  List <PollOption> options;
}


PollOption {
  Integer id;
  String option;
  Integer totalVotes;
}



My form (freemarker):


<@s.textfield name="poll.name" />
<@datepicker name="poll.startDate"/>
<@datepicker name="poll.finishDate"/>
<@s.textarea name="poll.question" rows="5"/>

<table id="tableAddPollOptions" cellspacing="0" width="100%">

                <tbody>
                <#assign rowIndex = 0>
                <#if poll.pollOptions??>
                                <#list poll.pollOptions as option>
                                                <tr>
                                                                <td>
 
<@s.hidden name="poll.pollOptions[${rowIndex}].id" />
 
<@s.textfield name="poll.pollOptions[${rowIndex}].option" />
 
<input type='button' onclick='dropMyRow(this);' value='remove option'>
                                                                </td>
                                                </tr>
                                                <#assign rowIndex = rowIndex
+ 1>
                                </#list>
                </#if>
                </tbody>

</table>
<br />                   
<a href="javascript:addPollOption();">add option</a>


Thanks,

Luciano Costa





 
____________________________________________________________________________
________
Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org