1
votes

My scenario:

The xpage ( document content ) has a complex structure. I have a 1st button which opens this xpage, having in the postNewDocument:

 Contr.replaceItemValue("txt_codformularmain","01") // I use this field as a flag. 

Now, there is another button which compose the same xpage ... but in this case, I do want the xpage to be different, in other words to have some additional / showed fields.

I could add another code at the postNewDocument, like this:

Contr.replaceItemValue("txt_codformularmain2","01")

Later on, in some views I will filter the listed documents by this 2 fields: some views will be listing the documents where txt_codformularmain=01, other views for txt_codformularmain2=01, and so on.

All the fields are on the same form element. ( I could create easily 2 different xpages, with 2 document contents, but in the form Properties at onOpen and onWebAccess settings, I can add only one xpage )

But, I think it isn't the best approach for this. Because in both cases, postNewDocument takes place, and both fields are having the value 01.

In classic lotus notes programming, I had used only one field ( flag ) and for every different button, inside the button's code I just changed the field value: 01, 02, and so on, before the newDocument had been composed.

Should I use another/ a better approach?

I might go for creating a new form with the fields needed there, and creating a new XPage binded to that form...

1
May be a better way is set a scope variable when open the page in the before page load. Next make to views with the different documents. And load these views based on the scope variableFrank van der Linden
but how can I set a scope variable to a value - depending on which button was clicked?Florin M.
the buttons are not on the same xpageFlorin M.
When you click a button you can set a sessionScop variable which can be used through out the application. And the Viewpanel should be wrapped inside a panel, so you can performance a partial refresh to load the correct data.Frank van der Linden

1 Answers

1
votes

dominoDocument.isNewNote() will tell you if it's a new document or not. You can compute visibility based on that.

If it's based on a field value, then again set the visibility based on what the value should be for the panel to be visible - instead of getComponent().getValue() use dominoDocument.getItemValueString() assuming it's a Text field for best practice. In the onblur event of the control that's bound to the field you're checking against, trigger a partial refresh. You will need to amend the default partial refresh settings if there is validation on the page.

Once you're comfortable with that technique, start thinking about using a dataContext to hold whether or not an area should be visible, and referencing that dataContext variable in the rendered property. The benefits of this are not only performance, but youo can give a better variable name to the dataContext to make it clearer when supporting the application what the logic is behind it being visible. For someone supporting the Notes Client app, for example, it's unclear without hunting what state "01" or "02" means. Descriptors like "newDoc", "published", etc have an advantage there.

Another method of optimisation would be to use a Dynamic Content control.

But it sounds like your XPage is going to be complex enough without adding more complexity at this stage.