cancel
Showing results for 
Search instead for 
Did you mean: 

Making a field read only (and bound) or editable depending on some criteria

Former Member
0 Kudos

Hi,

I am using Netweaver 2004s SP15 and Adobe Lifecycle Designer 7.1 with Web Dynpro for Java.

I am generating a PDF that contains a number of fields that are bound context values attribues.

Now I know according to certain criteria if any given field will have a value....

Now if such a given field has a value then it must populate the Adobe form and make that field read-only - so it can not be changed.

However, if that field has no value.. instead I need to make it editable.

I am re-implementing the application this will be used within; and the previous version had 8 different interactive forms to cater for the 8 different possible combinations of fields that would not have values.

I would really really prefer to have one interactive form to maintain with logic in it that determines dynamically if a field should be read-only or editable. (For example I could have a boolean context node that could be used)

Am I doomed to have to create 8 different forms? Or is there a way of doing this smarter?

Thanks to anyone who can point me to the light,

Ilan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi IIan,

Yes you are right. Your requirement is totally possible by using java script but you cannot do it by using webdynpro context node because there no option of binding a editable property of a ui element in adobe form with the webdynpro context.

Java script you can use like this.

For example your form design is like this.

Body Page

-


Subform

-


Field

so wright below code in initialize action of BodyPage.

if(BodyPage.Subform.Field.rawValue == null)

{

BodyPage.Subform.Field.access = "readOnly";

}

Thanks & regards

Ravindra Singh

Former Member
0 Kudos

I have got the techniques necessary for a solution working effectively.

But I have learnt that searching the SAP forums for information is unwieldy, difficult and sometimes useless. I am sure the answers I needed where somewhere in the history, but I never successfully managed to find them.

The previous post got me in the right direction

The final piece that I needed I eventually found in a blog page about "demystifying" the instance manager.

I will post the explanation of what I needed to do and then mark this question as answered this evening.

Former Member
0 Kudos

The steps to the solution are (as it seems to me)

(1) Have a context value flag for each of three dynamic conditions to use in the (if control structure)

(2) Put a script into the initialise for the page

(3) For individual fields just change the access property to "open" or "read-only" as appropriate

(4) For tables get the instance manager using the hidden "_" property.

(5) .. and then get a reference to the row; iterate through them changing the "access" property as appropriate

(steps and 4 and 5 were the most difficult to determine from the available documentation and googling)

eg


var count = eCard.ControlCard.EquipData._Item.count;
for ( var i =0; i<count; i++) 
{
   xfa.resolveNode("Output.Report.ControlCard.EquipData.Item["+i+"]").CurrentBalance.access="open"; 
}

jagdishwar_b
Active Participant
0 Kudos

Ilan Pillemer wrote:

But I have learnt that searching the SAP forums for information is unwieldy, difficult and sometimes useless. I am sure the answers I needed where somewhere in the history, but I never successfully managed to find them.

its possible to search effectively, if you go thru various techniques as you can see here: http://forums.sdn.sap.com/help/search-tips.html

for example, in your case, you can search for:

("read only" OR readonly) AND (condition OR criteria)

i searched the same:

http://forums.sdn.sap.com/search.jspa?threadID=&q=%28%22readonly%22ORreadonly%29AND%28conditionOR+criteria%29&objID=f155&dateRange=all&numResults=10&rankBy=10001

You can see very relevant results.

regards,

BJagdishwar.

Answers (2)

Answers (2)

Former Member
0 Kudos

I think its answered.. but I have changed it back to unanswered just to confirm that I have understood things properly.

Am I right?

Former Member
0 Kudos

hmmm....

I did a search through the forum using the phrase "javascript" and it turned out a lot posts that indicate that this should indeed be possible.

I am boggled, the original application was developed by an Indian outsourcing company that is well respected. The developer who took over maintenance of it told me that it was impossible to change the read only nature of the fields once set at design-time.

My search through the forum has turned up much to indicate that this design was idiotic and the "facts" I was given completely wrong.

grrrrrrrrrrrrrrrrr... I am marking this as answered now. I will have to learn some javascript.

Are there any caveats for using it within WDJ?

I am assuming I can do something simple in pseudo-code.. (I will need to work out the Javascript version).


if (hasOption1) {
  field.readonly = true;
  field.style = sunken;
}

else if (hasOption2) {
 ...
}

else if (hasOption3) {
 ...
}

etc

(There are only actually 3 options that can change.. but that results in 8 different possible forms)