Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Subject: Hiding a form field when a check box value is selected

Subject: Hiding a form field when a check box value is selected

2007-10-10       - By swapna reddy

 Back
I have created an interactive PDF Form dynamically from a bean. It has multiple
form fields like Textbox, selectbox,checkbox n so on...
 
 I am trying to figure out, how to hide a form fieled when a particular option
of checkbox/radiobutton/selectbox is selected. Where do I need to trigger the
event after creating a javascript function using writer.addJavaScript(..)? Is
it at the parent checkbox level or at the option level? How do I call the
Javascript, what wud be the action??
 
 Any help regarding the same would be highly appreciated.....The piece of code
am trying to execute is as follows:
 
 PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream("C:/
/SamplePDFForm.pdf"));
document.open();
writer.addJavaScript(
"function actionOnChange(){var question=this.getField('Component(s) Origin')
;app.alert('<P>Component(s) Origin</P>:'+this.getField('<P>Component(s) Origin<
/P>'));if(this.getField('Ruminant.Bovine').value=='On')){question.display =
display.hidden;app.alert('Bovine value:'+this.getField('Ruminant.Bovine').value
)} else question.display = display.visible;}",false);
 
 PdfPTable checkboxOptionsTable = new PdfPTable(3);
checkboxOptionsTable.setWidthPercentage(100f);
float[] relativeWidths = {5.0f,50.0f,45.0f};
checkboxOptionsTable.setWidths(relativeWidths);
PdfFormField multipleCheckbox = PdfFormField.createCheckBox(writer);
multipleCheckbox.setButton(PdfFormField.FF_MULTISELECT);
multipleCheckbox.setFieldName(questionDataVO.getQuestionText().trim());
PdfAppearance cbOff = cb.createAppearance(10, 10);
PdfAppearance cbOn = cb.createAppearance(10, 10);
cbOff.rectangle(1, 1, 8, 8);
cbOff.stroke();
cbOn.rectangle(1, 1, 8, 8);
cbOn.stroke();
cbOn.moveTo(1, 1);
cbOn.lineTo(9, 9);
cbOn.moveTo(1, 9);
cbOn.lineTo(9, 1);
cbOn.fillStroke();
laQuestionOptions  = questionBO.getAllQuestionOptions(questionDataVO
.getQuestionId());
for (int j = 0; j<laQuestionOptions.size();j++){
QuestionOptionsVO questionOptionsVO = (QuestionOptionsVO) laQuestionOptions
.get(j);
questionOptionsVO = (QuestionOptionsVO) laQuestionOptions.get(j);
PdfFormField multipleCheckbox1 = PdfFormField.createEmpty(writer);
multipleCheckbox1.setFieldName(questionOptionsVO.getControlLabelText());
multipleCheckbox1.setValueAsName(questionOptionsVO.getControlLabelText());
multipleCheckbox1.setValueAsString(questionOptionsVO.getControlLabelValue());
multipleCheckbox1.setAppearanceState("Off");
multipleCheckbox1.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", cbOff);
multipleCheckbox1.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", cbOn);
if("Ruminant".equals(questionDataVO.getQuestionText())& "Bovine".equals
(questionOptionsVO.getControlLabelText()))
{                multipleCheckbox1.setAdditionalActions(PdfFormField.AA_DOWN
,PdfAction.javaScript("actionOnChange();\r",writer));
}
multipleCheckbox.addKid(multipleCheckbox1);
PdfPCell cell = new PdfPCell();
cell.setCellEvent(new CheckboxFormField(writer,questionOptionsVO
.getControlLabelText(),multipleCheckbox1));
cell.setBorderColor(Color.white);
cell.setBorder(Rectangle.NO_BORDER);
checkboxOptionsTable.addCell(cell);
}
 
 
 Thanks
 Swapna.
 
 


swapna
     
-- ---- ---- ---- ---- ---- -----
5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.
<div>I have created an interactive PDF Form dynamically from a bean. It has
multiple form fields like Textbox, selectbox,checkbox n so on...</div>  <div>
&nbsp;</div>  <div>I am trying to figure out, how to hide a form fieled when a
particular option of checkbox/radiobutton/selectbox&nbsp;is selected. Where do
I need to trigger the event after creating a javascript function using writer
.addJavaScript(..)? Is it at the parent checkbox level or at the option level?
How do I call the Javascript, what wud be the action?? </div>  <div>&nbsp;</div
>  <div>Any help regarding the same would be highly appreciated.....The piece of
code am trying to execute is as follows:</div>  <div>&nbsp;</div>  <div
>PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream("C:/
/SamplePDFForm.pdf"));<BR>document.open();<BR><STRONG>writer.addJavaScript(<BR>
"function actionOnChange(){var question=this.getField('Component(s) Origin');app
.alert('&lt;P&gt;Component(s)
Origin&lt;/P&gt;:'+this.getField('&lt;P&gt;Component(s) Origin&lt;/P&gt;'));if
(this.getField('Ruminant.Bovine').value=='On')){question.display = display
.hidden;app.alert('Bovine value:'+this.getField('Ruminant.Bovine').value)} else
question.display = display.visible;}",false);</STRONG></div>  <div>&nbsp;</div>
 <div>PdfPTable checkboxOptionsTable = new PdfPTable(3);<BR
>checkboxOptionsTable.setWidthPercentage(100f);<BR>float[] relativeWidths = {5
.0f,50.0f,45.0f};<BR>checkboxOptionsTable.setWidths(relativeWidths);<BR
>PdfFormField multipleCheckbox = PdfFormField.createCheckBox(writer);<BR
>multipleCheckbox.setButton(PdfFormField.FF_MULTISELECT);<BR>multipleCheckbox
.setFieldName(questionDataVO.getQuestionText().trim());<BR>PdfAppearance cbOff =
cb.createAppearance(10, 10);<BR>PdfAppearance cbOn = cb.createAppearance(10, 10
);<BR>cbOff.rectangle(1, 1, 8, 8);<BR>cbOff.stroke();<BR>cbOn.rectangle(1, 1, 8,
8);<BR>cbOn.stroke();<BR>cbOn.moveTo(1, 1);<BR>cbOn.lineTo(9,
9);<BR>cbOn.moveTo(1, 9);<BR>cbOn.lineTo(9, 1);<BR>cbOn.fillStroke();<BR
>laQuestionOptions&nbsp; = questionBO.getAllQuestionOptions(questionDataVO
.getQuestionId());<BR>for (int j = 0; j&lt;laQuestionOptions.size();j++){<BR>
&nbsp;QuestionOptionsVO questionOptionsVO = (QuestionOptionsVO)
laQuestionOptions.get(j);<BR>&nbsp;questionOptionsVO = (QuestionOptionsVO)
laQuestionOptions.get(j);<BR>&nbsp;PdfFormField multipleCheckbox1 =
PdfFormField.createEmpty(writer);<BR>&nbsp;multipleCheckbox1.setFieldName
(questionOptionsVO.getControlLabelText());<BR>&nbsp;multipleCheckbox1
.setValueAsName(questionOptionsVO.getControlLabelText());<BR>&nbsp
;multipleCheckbox1.setValueAsString(questionOptionsVO.getControlLabelValue());
<BR>&nbsp;multipleCheckbox1.setAppearanceState("Off");<BR>&nbsp
;multipleCheckbox1.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", cbOff);
<BR>&nbsp;multipleCheckbox1.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On",
cbOn);<BR><STRONG>&nbsp;if("Ruminant".equals(questionDataVO.getQuestionText())
&amp; "Bovine".equals(questionOptionsVO.getControlLabelText()))<BR>&nbsp;{&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;multipleCheckbox1.setAdditionalActions(PdfFormField.AA_DOWN
,PdfAction.javaScript("actionOnChange();\r",writer));<BR>&nbsp;}<BR></STRONG>
&nbsp;multipleCheckbox.addKid(multipleCheckbox1);<BR>&nbsp;PdfPCell cell = new
PdfPCell();<BR>&nbsp;cell.setCellEvent(new CheckboxFormField(writer
,questionOptionsVO.getControlLabelText(),multipleCheckbox1));<BR>&nbsp;cell
.setBorderColor(Color.white);<BR>&nbsp;cell.setBorder(Rectangle.NO_BORDER);<BR>
&nbsp;checkboxOptionsTable.addCell(cell);<BR>}</div>  <div>&nbsp;</div>  <div>
&nbsp;</div>  <div>Thanks</div>  <div>Swapna.</div>  <div>&nbsp;</div>  <div>
&nbsp;</div><BR><BR>swapna<p>&#32;


     <!--4--><hr size=1></hr> 5, 50, 500, 5000 - Store N number of mails in
your inbox. <a href="http://in.rd.yahoo.com/tagline_mail_4/*http://help.yahoo
.com/l/in/yahoo/mail/yahoomail/tools/tools-08 (See http://ols-08.ora-code.com).html/">Click here.</a>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

©2008 junlu.com - Jax Systems, LLC, U.S.A.