1 package body WFA_HTML_UTIL as
2 /* $Header: wfhtmb.pls 120.5.12010000.7 2009/12/09 18:47:45 vshanmug ship $ */
3
4
5 --
6 -- Package Globals
7 --
8 result_button_threshold pls_integer := 3; -- Max number of submit buttons
9
10 --
11 -- GetUrl (PRIVATE)
12 -- Produce URL link in response portion
13 -- IN
14 -- nid -
15 -- description - instructions
16 -- value - url string not token substituted
17 procedure GetUrl(
18 nid in number,
19 description in varchar2,
20 value in varchar2)
21 as
22 urlstring varchar2(1950);
23 begin
24 -- Ignore if no URL provided
25 if (value is null) then
26 return;
27 end if;
28
29 htp.tableRowOpen;
30
31 -- Include description if needed.
32 -- NOTE: Description are printed here instead of in the prompt link
33 -- as for other fields, because the prompt is already used for the
34 -- URL itself.
35 if (description is not null) then
36 htp.tableData(description, 'right', cattributes=>'id=""');
37 else
38 htp.tableData(htf.br, cattributes=>'id=""');
39 end if;
40
41 -- Print URL
42 urlstring:=wf_notification.GetURLText(value, nid);
43
44 -- Bug 4634849
45 urlstring := wfa_html.encode_url(urlstring);
46 htp.p('<td id=""> <a href="'||urlstring||'">'||urlstring||'</a></td>');
47
48 htp.tableRowClose;
49
50 exception
51 when others then
52 wf_core.context('Wfa_Html_Util', 'GetUrl', value, description, to_char(nid));
53 raise;
54 end GetUrl;
55
56 --
57 -- GetField (PRIVATE)
58 -- Produce a varchar2/number/date response field
59 -- IN
60 -- name - field name
61 -- type - field type (VARCHAR2, NUMBER, DATE)
62 -- format - format mask
63 -- dvalue - default value
64 -- index - the attribute element number in the attribute list
65 --
66 procedure GetField(
67 name in varchar2,
68 type in varchar2,
69 format in varchar2,
70 dvalue in varchar2,
71 index_num in number,
72 nid in number,
73 nkey in varchar2)
74 is
75 begin
76 -- bug 7314545
77 null;
78 end GetField;
79
80 --
81 -- GetLookup (PRIVATE)
82 -- Produce a lookup response field
83 -- IN
84 -- name - field name
85 -- value - default value (lookup code)
86 -- format - lookup type
87 -- submit - flag include a submit button for result field
88 --
89 procedure GetLookup(
90 name in varchar2,
91 value in varchar2,
92 format in varchar2,
93 submit in boolean)
94 as
95 begin
96 -- bug 7314545
97 null;
98 end GetLookup;
99
100 --
101 -- GetButtons (PRIVATE)
102 -- Produce a response field as submit buttons
103 -- IN
104 -- value - default value
105 -- format - lookup type
106 --
107 procedure GetButtons(
108 value in varchar2,
109 format in varchar2,
110 otherattr in number)
111 as
112 begin
113 -- bug 7314545
114 null;
115 end GetButtons;
116
117 --
118 -- SetAttribute (PRIVATE)
119 -- Set response attributes when processing a response.
120 -- IN
121 -- nid - notification id
122 -- attr_name_type - attribute name#type#format
123 -- attr_value - attribute value
124 --
125 procedure SetAttribute(
126 nid in number,
127 attr_name_type in varchar2,
128 attr_value in varchar2,
129 doc_name in varchar2)
130 as
131 begin
132 -- bug 7314545
133 null;
134 end SetAttribute;
135
136 --
137 -- GetLookupMeaning (PRIVATE)
138 -- Retrieve displayed value of lookup
139 -- IN
140 -- ltype - lookup type
141 -- lcode - lookup code
142 -- RETURNS
143 -- Displayed meaning of lookup code
144 --
145 function GetLookupMeaning(
146 ltype in varchar2,
147 lcode in varchar2)
148 return varchar2
149 is
150 meaning varchar2(80);
151 begin
152 select WL.MEANING
153 into meaning
154 from WF_LOOKUPS WL
155 where WL.LOOKUP_TYPE = GetLookupMeaning.ltype
156 and WL.LOOKUP_CODE = GetLookupMeaning.lcode;
157
158 return(meaning);
159 exception
160 when no_data_found then
161 return(lcode);
162 when others then
163 wf_core.context('Wfa_Html_Util', 'GetLookupMeaning', ltype, lcode);
164 raise;
165 end GetLookupMeaning;
166
167 --
168 -- GetUrlCount (PRIVATE)
169 -- IN
170 -- nid - notification id
171 -- OUT
172 -- urlcnt - number of urls as reponse attributes
173 -- urlstrg - one of the urls if it exist
174 -- this is generally discarded unless there is only one
175 procedure GetUrlCount(
176 nid in number,
177 urlcnt out nocopy number,
178 urlstrg out nocopy varchar2)
179 is
180 buf pls_integer;
181 begin
182 -- bug 7314545
183 null;
184 end GetUrlCount;
185
186 --
187 -- GetResponseUrl (PRIVATE)
188 -- Return single response url.
189 -- NOTE: this assumes there is exactly one response url attribute.
190 -- IN
191 -- nid - notification id
192 -- RETURNS
193 -- Response url
194 --
195 function GetResponseUrl(
196 nid in number)
197 return varchar2
198 is
199 buf varchar2(4000);
200 begin
201 select text_value
202 into buf
203 from WF_NOTIFICATION_ATTRIBUTES NA,
204 WF_MESSAGE_ATTRIBUTES_VL MA,
205 WF_NOTIFICATIONS N
206 where N.NOTIFICATION_ID = nid
207 and NA.NOTIFICATION_ID = N.NOTIFICATION_ID
208 and MA.MESSAGE_NAME = N.MESSAGE_NAME
209 and MA.MESSAGE_TYPE = N.MESSAGE_TYPE
210 and MA.NAME = NA.NAME
211 and MA.SUBTYPE = 'RESPOND'
212 and MA.TYPE = 'URL'
213 and ROWNUM = 1;
214
215 return(buf);
216
217 exception
218 when others then
219 wf_core.context('Wfa_Html_Util', 'GetResponseUrl', to_char(nid));
220 raise;
221 end GetResponseUrl;
222
223 --
224 -- GetDisplayValue (PRIVATE)
225 -- Get displayed value of a response field
226 -- IN
227 -- type - field type (VARCHAR2, NUMBER, DATE, LOOKUP, URL)
228 -- format - field format (depends on type)
229 -- tvalue - text value
230 -- nvalue - number value
231 -- dvalue - date value
232 -- RETURNS
233 -- Displayed value
234 --
235 function GetDisplayValue(
236 type in varchar2,
237 format in varchar2,
238 tvalue in varchar2,
239 nvalue in number,
240 dvalue in date)
241 return varchar2
242 is
243 s0 varchar2(2000);
244 value varchar2(4000);
245 begin
246 if (type = 'VARCHAR2') then
247 value := tvalue;
248 elsif (type = 'NUMBER') then
249 if (format is null) then
250 value := to_char(nvalue);
251 else
252 value := to_char(nvalue, format);
253 end if;
254 elsif (type = 'DATE') then
255 -- <bug 7514495>
256 value := wf_notification_util.GetCalendarDate( wf_notification_util.getCurrentNID() , dvalue, format);
257 elsif (type = 'LOOKUP') then
258 value := wfa_html_util.GetLookupMeaning(format, tvalue);
259 elsif (type = 'URL') then
260 value := tvalue;
261 elsif (type = 'ROLE') then
262 wf_directory.GetRoleInfo(tvalue, value, s0, s0, s0, s0);
263 else
264 -- Default to return text value unchanged
265 value := tvalue;
266 end if;
267
268 return(value);
269
270 exception
271 when others then
272 wf_core.context('Wfa_Html_Util', 'GetDisplayWindow', type, format,
273 tvalue, to_char(nvalue), to_char(dvalue));
274 raise;
275 end GetDisplayValue;
276
277 --
278 -- GetDenormalizedValues
279 -- Populate WF_NOTIFICATIONS with the needed values with supplied langcode.
280 -- Then returns those values via the out variables.
281 -- IN:
282 -- nid - notification id
283 -- langcode - language code
284 -- OUT:
285 -- from_user - display name of from role
286 -- to_user - display name of recipient_role
287 -- subject - subject of the notification
288 --
289 procedure GetDenormalizedValues(nid in number,
290 langcode in varchar2,
291 from_user out nocopy varchar2,
292 to_user out nocopy varchar2,
293 subject out nocopy varchar2)
294 is
295 begin
296 Wf_Notification.Denormalize_Notification(nid=>nid,langcode=>langcode);
297
298 begin
299 select FROM_USER, TO_USER, SUBJECT
300 into from_user, to_user, subject
301 from WF_NOTIFICATIONS
302 where NOTIFICATION_ID = nid;
303 exception
304 when OTHERS then
305 from_user := null;
306 to_user := null;
307 subject := null;
308 end;
309
310 exception
311 when OTHERS then
312 wf_core.context('Wfa_Html_Util', 'GetDenormalizedValues',
313 to_char(nid), langcode);
314 raise;
315 end GetDenormalizedValues;
316
317 end WFA_HTML_UTIL;