I have an an html page, currently, with two procedures. Controlled by a drop down with user id's. (passing value of drop down to amper in procedures). I need for the procedures to default to the current user. I have tried doing a -DEFAULT in the individual procedures. This works for them, individually, but on the html, control is by the drop down. Which is defaulting to ALL.
I have a XML procedure populating the drop down. I'm thinking I need this procedure to default to whomever is signed on, but still list the other values.
Any ideas?This message has been edited. Last edited by: Kerry,
WebFOCUS 768 OS/400 HTML, also quite a few active reports and excel.
February 11, 2010, 09:50 AM
GinnyJakes
I haven't tried this so don't know if it would work. Can you put a GETUSER in your load procedure and match the results of that to your userid file. If an entry matches, make it be first in the list followed by the rest of the ids?
I've worked a little example using the CAR table implementing Ginny's suggestion:
-DEFAULT &MYCOUNTRY = 'JAPAN';
DEFINE FILE CAR
SORT_SQ/I2 = IF COUNTRY EQ '&MYCOUNTRY' THEN 0 ELSE 1;
END
TABLE FILE CAR
PRINT
CAR
BY SORT_SQ NOPRINT
BY COUNTRY
ON TABLE PCHOLD FORMAT XML
END
You'll get a list of values ordered alphabetically by country except for the one that matches your choice (&MYCOUNTRY) which, if found, will appear first in the list.
Since you are using XML to populate the dropdown list, I don't know if this will be useful. But maybe it can be more food for thought.
We often use -MRNOEDIT -INCLUDE to call common procedures at the top (before the -HTMLBEGIN) of our HTML launch pages to populate standard dropdown lists. These common procedures will extract the necessary data for the dropdown list and then use code similar to the following (HTML_RPTYEAR.fex) to generate the HTML code for the dropdown and set the default value to an existing value. The current value of variable &RPTYEAR, whether by default or as previously chosen by the user, is "selected" as the default for the generated HTML code.
-DEFAULT &RPTYEAR = &DATEYY
-*
DEFINE FILE <filename>
RYOPTION/A50 = IF (RPT_YEAR EQ '&RPTYEAR')
THEN ('<option selected value="' | RPT_YEAR || '">' || RPT_YEAR || '</option>')
ELSE ('<option value="' | RPT_YEAR || '">' || RPT_YEAR || '</option>');
END
-*
TABLE FILE <filename>
PRINT RYOPTION
BY RPT_YEAR NOPRINT
ON TABLE SAVE AS RYHTML
END
The launch page uses the HTML code generated above to populate the dropdown list for report year:
This message has been edited. Last edited by: Dan Satchell,
WebFOCUS 7.7.05
February 11, 2010, 01:45 PM
Francis Mariani
Amber,
If you're using Dev Studio HTML Layout Painter, this might be easy.
You already have the User ID. Simply add the JS function called "onInitialUpdate()" to the code (as per instructions within the html code generated by HTML Layout Painter), and JS to select the User Id from the drop-down.
for (var i = 0; i < SelectObject.length; i++)
{
if (SelectObject[i].value == TextValue)
{
SelectObject.selectedIndex = i;
break;
}
}
This is old-fashioned JS code, there may be better examples out there.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 12, 2010, 04:31 AM
Tony A
If you think about this logically then you will see that Neftali's Ginny's suggestion will suit you completely(?)
When your fex is called to create the XML return file, the fex is executed using the current users credentials so all you have to do in your fex is to capture the user id (using GETUSER or CNCTUSER) and then apply Ginny's / Neftali's logic to ensure that the userid is at the top of the list.
Also, set the "addalloption" attribute to 0 if you use the editor,
or
in HTML painter, select the combo box and then in the properties dialogue click the parameters tab, then deselect the Add "ALL" option.
T
Edited to correctly attribute the original suggestion by Ginny This message has been edited. Last edited by: Tony A,
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
February 12, 2010, 05:43 AM
Tony A
.... and just because it's Friday , here's an example -
APP PREPENDPATH IBISAMP
FILEDEF USERLIST DISK USERLIST.FTM (APPEND
-SET &Userid = GETUSER('A25');
-RUN
-WRITE USERLIST &Userid
TABLE FILE BROKERS
BY BROKER_NAME
ON TABLE HOLD AS USERLIST FORMAT ALPHA
END
DEFINE FILE USERLIST
SORT_ORD/I1 = IF BROKER_NAME EQ '&Userid' THEN 0 ELSE 1;
END
TABLE FILE USERLIST
SUM FST.BROKER_NAME
BY SORT_ORD NOPRINT
BY BROKER_NAME
ON TABLE PCHOLD FORMAT XML
END
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
February 17, 2010, 02:09 PM
Amber
Great!! Thank you all for your help!
WebFOCUS 768 OS/400 HTML, also quite a few active reports and excel.