Cannot enable viewstate? - asp.net-2.0

I have a web apllication with wizard control with 4 step index. Each having a dynamically editable grid which need to put only valid data & goto next.
In one step which have 2 columns which are not require to be editable because it has set its value from previous field by calculation, done with javascript.
But problem is that when we decalre these field as a enable false or read only mode then it works but can not able maintain state means its value goes off when we change the step index changed. (If that field are editable then it works ok.)
Also I tried it by use of label field but the same thing happen when the step changes label can not maintan its state (its value clears when step changes).
Please give me idea how to resolve this problem. Also each step has a dynamically created editable grid.
Thanks & Regards,
Girish

Well, if your javascript is doing the calculation from another field that is set by the user, then why couldn't you just redo that calculation on the server side when switching to the next step. I am assuming that the "value from previous field" is getting passed back to the server.
Another solution would be to have your javascript populate a hidden field too (in addition to the one viewable by the user). Then you just read that hidden field.

Related

Application Express: Anonymous PL/SQL Block and Bind Variables

I'm having an issue binding the value of a page item to a declared variable in an anonymous PL/SQL block process.
The problem is that the page item (:P4550_REQUESTOR) is not populated with a value until a conditional is met. It appears that the PL/SQL block process is binding the variable to an empty value as soon as the page is loaded, despite the fact that the process does not fire until a specific button has been clicked.
Here is my code:
DECLARE
v_email_to app_user.email%type;
v_requestor VARCHAR2(15);
BEGIN
v_requestor := :P4550_REQUESTOR;
BEGIN
SELECT email INTO v_email_to
FROM app_user
WHERE userid = v_requestor;
END;
SEND_APEX_MAIL (
v_email_to,
'Your vacancy request has been rejected.'
|| chr(10)
|| 'Emailed to: ' || v_email_to
|| chr(10)
|| 'Requestor: ' || v_requestor,
'Vacancy Request Rejected'
);
END;
Does anyone have any thoughts on this?
The block works just fine if I hard code a value to v_requestor. If I try to get the value of P4550_REQUESTOR after the page has loaded, it is empty. After clicking the edit button, P4550_REQUESTOR is populated.
** **MORE DETAIL** **
P4550_REQUESTOR is a page item that resides within the Vacancy Request region which is only displayed when a conditional is met. Specifically, the conditional is an edit button associated with a table row that is created on page load. Clicking the edit button causes the details region to display, and the associated page items to be populated.
The page item values in the Vacancy Request region are populated via an Automated Row Fetch which fires After Header.
P4550_REQUESTOR has a Source Type of DB Column.
The process that fires the code above is set to fire On Submit - After Computations and Validations
If I log the value of P4550_REQUESTOR when the page loads, it shows null. If I log the value after clicking the edit button, I get the expected string value.
Process Flow Control in Oracle APEX
(This is actually useful to think about in other programming disciplines and environments.)
Problem Defined
The problem is that the page item (:P4550_REQUESTOR) is not populated with a value until a conditional is met. It appears that the PL/SQL block process is binding the variable to an empty value as soon as the page is loaded, despite the fact that the process does not fire until a specific button has been clicked.
The problem statement reworded in Apex terminology and presented in the form of an actual question:
There is a REPORT REGION on the page which contains the result of a direct reference to a data table/view. This report is managed by an Apex process called "Automated Fetch" and is initiated automatically by the loading of the page headers.
There is a FORM ITEM on a page which which is populated conditionally by a BUTTON ITEM selection made by the user. The BUTTON ITEM is part of the report results.
There are multiple button items. Each is associated with a value for each report record.
If the user does not select the BUTTON ITEM from the REPORT REGION, the FORM ITEM remains unassigned and contains a "null" value.
There is a defined PL/SQL block of code which is set to execute when a SUBMIT BUTTON item is pressed (also on the same page). Why does my code block (defined page process) run with a null value when it is triggered without first pressing a BUTTON ITEM from the REPORT REGION first?
Event Driven Program Design for Procedural Programmers
The answer is not obvious if you think under the paradigm of a procedural language. Without diving into a lecture on the topic, here's a visual layout of the problem space of the OP that I cooked up to illustrate how the problem can be made more obvious:
This is my Apex page design in implementation. It's generic enough to use as a template for other Apex designs. There are no flow arrows on this diagram because it's a stateful system. One thing causes another thing to happen and so on... but not always and not all at the same time.
Use Cases for Apex UI Page Designs
Try walking through a few use cases to understand how the elements broken down in the diagram operate together. Each user may take any number of click combinations and interactions, but there is a commonality:
They all enter the same initialized conditions on page load.
They all leave the page by: navigating elsewhere or through the SUBMIT button event.
Use Case #1
User chooses {MyPage:SQLReport:ThisButton} from one of the records in {MyPage:SQLReport}
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial null value.
User selects {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
Use Case #2
User enters page and reviews results displayed in the {MyPage:SQLReport} region.
User decides no additional input is necessary and then selects the {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
(a note: the state of form item {MyPage:HTML-Region:ThisItem} has not been changed from the initial null value at this point... after the submit button has been selected)
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
Use Case #3
User chooses {MyPage:SQLReport:ThisButton} from one of the records in {MyPage:SQLReport}
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial null value.
User chooses {MyPage:SQLReport:ThisButton} from a different selection from one of the records in {MyPage:SQLReport}.
According to {MyPage:SQLReport:ThisButton} #3, the value associated between the report record and the button item is passed to: {MyPage:HTML-Region:ThisItem}
The form item state has been updated and changed from the initial value stored in step (2).
User selects {MyPage:HTML-Region:ThisSubmit} button to inform the system to continue on.
The submit button executes the defined PL/SQL procedure block: {MyPage:RunCodeBlock}
The difference between each case should illustrate why the dependent value (ThisItem, or more specifically, page item P4550_REQUESTOR) is null in one use case vs. the other.
Building a Physical Implementation (An Apex Page)
The table I used is called STAR_EMPS. It is similar to the EMP table but has only three columns: ename, deptno and salary. Although it is not super important, this is the data set I used to populate STAR_EMPS:
I used a simple two-column table named STAR_EMPS_LOG for capturing the output of a successfully executed procedure call. You could accomplish the same with just one column, but I wanted a sequential id for tracking the order each event was recorded- for running multiple test cases. The procedure is one of several defined processes kept on this page:
contained in: {MyPage:RunCodeBlock} is below:
DECLARE
-- output from this procedure will be recorded in the star_emps_log
-- table. {MyPage:RunCodeBlock}
mycelebrity star_emps.ename%TYPE:= :P17_CELEBRITY_NAME;
mylogmessage star_emps_log.log_message%TYPE;
BEGIN
-- Conditional; changes message based on the value set for the
-- page item.
if mycelebrity is null then
mylogmessage:= 'No button was pressed on the previous page.';
else
mylogmessage:= 'The user selected: ' || mycelebrity ||
' from the report list.';
end if;
-- populate value from the page item.
INSERT INTO star_emps_log (log_message)
VALUES (mylogmessage);
commit;
END;
This is how the page layout was set up:
As in your example, I made a {MyPage:SQLReport} region with its supporting elements. The SQL Report represents a query directed at the source data table.
{MyPage:Form} has been renamed to {MyPage:HTML-Region}.
{MyPage:SQLReport} is defined by a SQL query, there is also a mock column to use as a place holder for placement of the "edit" buttons.
{MyPage:SQLReport:ThisButton} The button specifications are detailed through this:
The TWO Page processes: PROCESS and BRANCH need to be linked with the same settings referencing a BUTTON triggering Item.
User Interface Test Cases
Run through the three suggested scenarios to get started. Verify that the system is interpreting the requests correctly. This is what the page layout looks like:
The two processes on the system have a definition that wasn't mentioned in previous discussions may solve our original problem at hand:
Some Parting Thoughts
It is a good thing this turns out to be a trivial case once broken down. The diagramming method described here should scale to other Apex applications of varying complexity. There is considerable utility in stepping away from the code, locking down on terminology and trying to describe systems and processes without actual code. Please be sure to share any stories if this approach helps with your own Oracle Apex design challenges.
Onward!
The original, verbose answer seems to way overcomplicate the issue. The session state concepts manual covers this behaviour more succinctly.
Should P4550_REQUESTOR be a normal item created from a wizard, using :P4550_REQUESTOR will return a value in processes running post submit because the submit processes moves values in browser to session state.
If P4550_REQUESTOR is rendered conditionally, then it will always be null and I'm not sure what would happen if you tried to set it - probably depends how.
On a similar note, if you used &P4550_REQUESTOR. to parameterise the process, you would face the behaviour originally described (and made the code less secure)

Data copied between rows on form's datagrid

Within AX 2009, I have, through compare and compile, added two new controls within a datagrid on a form, a Real edit and a combobox. I have compiled with no issues. The Allow Edit property is set to Yes on both controls.
However, on the form, if I edit one row, whether typing a new number with Real edit or combobox, and don't hit Save but hit the Down Arrow key, the data I typed on the previous records is duplicate in the next record and so on until I release the Down Arrow key, rather than just setting the focus on a new record.
The table where these fields were created doesn't exhibit this behavior. The focus simply moves to the next record and what was typed will not carry over to the next record. Only the form does this...
Has anyone seen this behavior before with AX forms?
You may have omitted to specify the data source on the grid itself?
Or if the new controls are based on Edit methods on the data source, have you got the data source parameter in the method signature?
see http://msdn.microsoft.com/en-us/library/aa637541(AX.10).aspx

Wizard control not retaining state between steps

I have a wizard control and in one of the steps, I dynamically build a table. If I move forward to the next step and decide to return back to the step with the table, the table is destroyed and only the header row is there. I set up some test scenarios and the bottom line is that when you leave the step, the table is wiped out.
I have view state enabled and set to true. What am I doing wrong?
Problem solved....disable view state.

How to create a form with variable no. of field set

I have to design a page for user information, for some background verification purpose, at my work. I need a set of fields for address, total count of which will be selected by user to update the form with that many fields. So, if user selects 3, form will have 3 set of address fields. Similar concept for work and education details.
Right now, I am passing the count to a handler page, which checks total count, and return it along with querystring, back to the main page. I am able to update the no. of fields, this way, but, all values are lost, once I return to the form. There are a lot of fields to even use session object for every value. Also, it resets the count of other such field set to 0. So, if I select 4 in address field, it renders four set of address fields, but fields for other details are gone.
I need to know, if it is possible to update the fields, using just one page, instead of creating a handler file to handle the redirect, so that I don't lose other data.
Sorry, for sounding a bit confusing. Will update the question, if needed.
Edit:
Similar blocks are there for education and work details. I want the update button to update the block, with that many fields, while retaining the values already entered by the user.
I have finally shifted the update code to one page. And the total count of blocks, is calculated by this way.
if request.form("addresscount") <> "" then
varaddresscount = request.form("addresscount")
else
varaddresscount = 1
end if
varaddresscount is used to loop through the html code which renders address fields. Even with this method, if I click on update button to change the total field count, every value entered by user is reset to default. Is there a way to retain the no. of fields without using session object, as there are way too many fields for which I have to store the value in session.
Why not have just a "add address" button that, whenever clicked, adds a extra set of input boxes using Javascript? That solves a lot of your problems regarding retaining the data on already filled in fields AND it makes it easier for the user.

Auto-Incrementation in InfoPath 2010 Form

I have a form in which I am attaching a workflow to. The form has a number that will be auto-generated. For example the first number will be 1, the next time the form is opened the number should be 2, so on and so forth. The issue I am having is: in the Default Value under the Text Box Properties I have the Value as: count(mynumber QuoteNumber) +1. When the form is generated the first and only number is 2 the number begins at 2 and never increases. Can someone help me with this or explain what I may be doing wrong? Thank You. I'm not using visual studio.
Rachel: I have fought with this problem since InfoPath 2007. Here is how I do it.
Since you say you are attaching a workflow, I assume you are using the from in SharePoint.
1 - create your form library in SharePoint
2 - use InfoPath to design the form. When you publish the form to SP, make sure you promote AT LEAST the ID field you want to auto-inc. (I usually promote every field in my forms, 'cause I like to use them like SP lists.)
3 - In SP, create one new form and manually set the ID field to the starting number for your form series.
4 - return to InfoPath designer and re-open your form template.
5 - create a new data source to receive data from your SP form library and specify your form library as the source, and the ID field as a data element. Name the data source something like “ID Lookup”.
6 - open the properties of the field you want to auto-inc on your form and, in the default value box, select function, then choose the MAX function.
And add “+1” after the function to increment by 1.
Now, double-click in the field are of the Max function. You will see a dialog showing your form fields. Notice the drop-down at the top of the dialog – here you can choose the data source (notice I named mine “sales Contracts” in this example). If you select the data source you created in step 5, you will see a dialog showing you a couple of data branches.
Expand the ‘dataFields’ branch until you see the field you want to auto-inc. Click on this.
Your formula dialog will look something like:
max(ID_X0020) + 1
With your field name instead of the 'ID' in the Max function – the function will now return the Maximum value of the field IN THE FORM LIBRARY, plus 1.
Save the form in InfoPath and try previewing it. You will probably get a security warning – your InfoPath form is grabbing data from your SharePoint library on the fly. You may even get asked to re-enter your password (I usually do). When the new, blank form is displayed in InfoPath preview, you should see you ID field filled in with a value one greater that the number in that field of your SP library.
There is one huge Gothca with this method - if users re-open a completed form to edit it, the formula will probably try to replace the ID number. If your users don't edit the forms after they are submitted, the this will work for you.
Hope this makes sense.
You aren't doing anything wrong - you just have to change how you think about "forms" a bit. Remember a form is just like a word document template. Suppose you save a word document on your hard drive with a blank spot to fill in your name. Later you open the template, type your name, and save a copy as V1.doc. When you go back and open the template again - your name is not there because it was saved in V1.doc. Everytime you open the template you start again from scratch.
Infopath forms that you design and that the user fills out are templates (.xsn files). When the user fills it out and saves it they are really saving a copy which is only data (.xml files). The .xsn template doesn't change when users interact with it.
So to answer your question - there is no way directly in InfoPath to cleanly keep track of an auto incrementing ID. You will need to tap into some code (webservice, sharepoint, etc) to do that. You could also consider making the ID a GUID (which infopath does support) but it won't be auto incrementing and it won't look "clean" if it has to be displayed/used by real people.

Resources