cancel
Showing results for 
Search instead for 
Did you mean: 

ClassCast exception in DoModifyView(), when trying to make Form dynamic

Former Member
0 Kudos

Hi,

I have a Webdynpro java application, where i need to make the interactive form dynamic.

So, in the DoModifyView() of my view, i used the code:

IWDInteractiveForm iForm2 = (IWDInteractiveForm) view.getElement("ainf_actulfr");
iForm2.setDynamicPDF(true);

However, it shows a warning saying the code is deprecated.

So, i tried using the new code:

IWDPDFDocumentInteractiveFormContext IForm3 = (IWDPDFDocumentInteractiveFormContext) view.getElement("ainf_actulfr");

However, at runtime, this throws the exception:

java.lang.ClassCastException

at com.lti.pmp1.views.form.FormView.wdDoModifyView(FormView.java:150)

How do i solve this?

Regards,

Hanoz

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Have you tried this

IWDPDFDocumentCreationContext context = WDPDFDocumentFactory.getDocumentHandler().getDocumentCreationContext();

context.setDynamic(true);

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

I believe the code you provided, is to be used if you want to create a pdf at runtime.

In my case, the interactive form Element is already present in the view at design time.

All i want to do, is set the dynamicity of that Interactive form.

I want to use IWDPDFDocumentInteractiveFormContext because it will also allow me to add attachemnts to an existing form.

Thanks & Regards,

Hanoz

Former Member
0 Kudos

I have no idea about interactive forms but from reading the Javadoc I would guess you have to do something like this:


IWDInteractiveForm form = (IWDInteractiveForm) view.getElement("formID");
IWDPDFDocumentInteractiveFormHandler handler = WDPDFDocumentFactory.getDocumentHandler(wdThis, "formID");
handler.getDocumentContext().setDynamic(true);

But note that the Javadoc for setDynamic() says:

"A PDF document can either be static or dynamic in nature. Dynamic PDFs are capable of changing their layout/behaviour at runtime based on the action/event triggered on the document. One example could be to hide or display certain portion of the document based on a button click or any other UI event on the document. Should you need to deal with a dynamic PDF, you need to set this flag to true while creating the PDF document. setDynamic is not effective on an existing PDF document."

Armin

Former Member
0 Kudos

Hi Armin,

Thanks for the code, but it does not work because

getDocumentHandler(wdThis, "formID");

does not work in the DoModifyView() of a view

This is because getDcoumentHandleer(arg1, arg2) expects IWDController as arg1.

Besides, i have used :

IWDInteractiveForm iForm2 = (IWDInteractiveForm) view.getElement("ainf_actulfr");
iForm2.setDynamicPDF(true);

on an Interactive form UI element, created at design time, with mode: updateDataInPdf.

Regards,

Hanoz

Edited by: Hanoz Tarapore on Jul 30, 2008 7:30 PM

Former Member
0 Kudos

Ok, using "wdThis" was only a guess (I have no IDE open). Replace it by whatever expression that gives you the view controller instance inside wdDoModifyView().

Armin

Former Member
0 Kudos

Hi Armin,

I tried that, but Since it is within the DoModifyView(), It does not accept any wd<controller> other that wdthis, & wdcontext...

It gives an error saying: cannot make a static reference to the non-static field wdcontrollerAPI

Regards,

Hanoz

Former Member
0 Kudos

Just pass the "view" reference into this method.

Armin

Former Member
0 Kudos

Hi Armin,

You are a Genius!!...it worked,

I could not only make it dynamic, but could also pass attachemnts to it!!..

Thanks a lot,

Hanoz

Former Member
0 Kudos

Hi Armin,

Can you please have a look at these Questions too?

Regards,

Hanoz

Former Member
0 Kudos

I have the similar warning message. Can you please let me know how did you get rid of the warning message. Please let me know your final code which worked.

Answers (0)