Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CASE-OPENED] Selection Required
Go
New
Search
Notify
Tools
Reply
  
[CASE-OPENED] Selection Required
 Login/Join
 
Guru
posted
Anyone know how to turn Selection Required on or off via javascript in WF8?

This message has been edited. Last edited by: <Kathryn Henning>,


Prod WF 8.1.04, QA WF 8.2.03, Dev WF 8.2.03
 
Posts: 277 | Registered: October 10, 2006Reply With QuoteReport This Post
Master
posted Hide Post
There is no specific settings to enable/disable this option. you need to code to get this.

Hope this helps.

Thanks,
Ram
 
Posts: 542 | Location: Dearborn, MI | Registered: June 03, 2009Reply With QuoteReport This Post
Gold member
posted Hide Post
You can do it either using javascript or jquery and you need to write the code based on the requirement. If you have some specific scenario, then provide more details. We might be able to help you.

Thanks,
Pravin


WebFOCUS 7703
Windows, All Outputs
pravinsinghwebfocus.blogspot.com
 
Posts: 51 | Location: WebFOCUS 7.7.03 | Registered: June 19, 2014Reply With QuoteReport This Post
Guru
posted Hide Post
Ok.
I have 2 calendar controls for 'Date Range' and a tree control for 'Time Frame'. There is a radio button to choose either one of these date options.
I want to turn on 'selection required' if the user selects the 'Time Frame' tree control but have this ignored if the user selects the 'Date Range' calendar controls. I currently disable the control not selected but this does not turn off the 'Selection Required' attribute that can be set in the 'Setting' for a control.

I'm pretty sure I can do this with brute force by checking an array of all the elements retrieved from the tree control, to see if any element has been selected, but I want to see if there is a better way.

Any ideas?

Thanks.



Greg



current client: WF 8.1.05 & 8.2 - Windows 7 64bit - Tomcat 7 - MRE / BID - IE11

local: WF 8.2 - Windows 7 64bit - Tomcat 6 - MRE / BID - FOCUS - IE11

PMF 8
 
Posts: 287 | Location: Boston/New England | Registered: February 12, 2006Reply With QuoteReport This Post
Virtuoso
posted Hide Post
There's a "Selection & Validation" property in HTML Composer that should toggle validation for controls, but it isn't working the way it is designed to and I've had a case open for 2 months now and it's currently in Product Division.

If we still had access to the HTML, we could simply add in a 'required' attribute to the controls (if it doesn't mess up the GUI-generated code), but no...they took out the HTML tab in AppStudio because (from what I've heard) they don't want to deal with customer support calls for when the customer is too dumb to avoid messing with GUI-generated code...which I don't blame them, but taking out access to all HTML is just absurd.


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
 
Posts: 1119 | Location: USA | Registered: January 27, 2015Reply With QuoteReport This Post
Member
posted Hide Post
I know this is an old case, but I have the same requirement and have been unable to find a successful solution in my research. I have a radio button which allows the user to select the criteria they want to use to run a report. The first option is using a begin and end date. The second option is to enter in a specific contract id. If they select the first option I check the value of the radio button and will show the calendar controls and hide the contract id control (edit box). What I also want to do is to toggle the controls to be required or not depending on the selection. If they select the dates option, then the dates would be required and the contract id would not be required. I've tried using java script to toggle the required attribute as I can't find anything in the webfocus functions to do this. If I set the date controls to _FOC_NULL for example when the user clicks on the Contract ID selection option, and the focexec runs ok but if they click back on the Dates option, the actual word "_FOC_NULL" shows up in the calendar text box.

I am not javascript savvy so I may have numerous things wrong with this function and I have lots of alerts in it (don't laugh) .... but here is the code.

function showSelOption(event)
{
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
// TODO: Add your event handler code here
var test2 = [];
var test2 = IbComposer_getCurrentSelection('radio1Grp');
if (test2 == 'DATES')
{ alert("in dates")
begdateCntl.setAttribute('required','required');
enddateCntl.setAttribute('required','required');
contidCntl.removeAttribute('required');
IbComposer_triggerExecution('showDates');
IbComposer_triggerExecution('hideContid');
IbComposer_setCurrentSelection('contidCntl','_FOC_NULL', false);
var begdateb1 = IbComposer_getCurrentSelection('begdateCntl');
var enddateb1 = IbComposer_getCurrentSelection('enddateCntl');
alert("begdateb1")
alert(begdateb1)
alert("enddateb1")
alert(enddateb1)
alert("contidCntl")
alert(contidCntl)
} else if (test2 == 'CONTID')
{
var begdateb2 = IbComposer_getCurrentSelection('begdateCntl');
var enddateb2 = IbComposer_getCurrentSelection('enddateCntl');
alert("begdateb2")
alert(begdateb2)
alert("enddateb2")
alert(enddateb2)
begdateCntl.removeAttribute('required');
enddateCntl.removeAttribute('required');
contidCntl.setAttribute('required','required');
IbComposer_triggerExecution('hideDates');
IbComposer_triggerExecution('showContid');
IbComposer_setCurrentSelection('begdateCntl','_FOC_NULL', false);
var begdatea2 = IbComposer_getCurrentSelection('begdateCntl');
alert("begdatea2")
alert(begdatea2)
IbComposer_setCurrentSelection('enddateCntl','_FOC_NULL', false);
var enddatea2 = IbComposer_getCurrentSelection('enddateCntl');
alert("enddatea2")
alert(enddatea2)
}
}
//End showSelOption


WF 8.2.4 Windows
Mainframe
Oracle/DB2/SQL Server
App Studio
Tomcat/Servlet
 
Posts: 11 | Registered: May 23, 2004Reply With QuoteReport This Post
Member
posted Hide Post
PS my profile is old. We are in WebFOCUS 8.2.4 using App Studio in the Window environment.


WF 8.2.4 Windows
Mainframe
Oracle/DB2/SQL Server
App Studio
Tomcat/Servlet
 
Posts: 11 | Registered: May 23, 2004Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Do not use the require option at all. Select the "Not required/no validate" option from the "Selection & Validation" property of your controls and perform the validation yourself.
Something such as this. The code has not been validated/tested and may need more line of code. This is just to give you an idea.
Searching the web for java script will give you plenty of sample

function RUN_BTN_onclick(event) {
  var eventObject = event ? event : window.event;
  var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
  var isValid = validateParams(this);
  if (isValid != true)
  {
      ctrl.stopPropagation();
      return;
  }
}
function validateParams(ctrl)
{
  begdateCntl.style.backgroundColor="white";
  enddateCntl.style.backgroundColor="white";
  IbComposer_getComponentById("contidCntl").style.backgroundColor="white";
  var tstType = IbComposer_getCurrentSelection('radio1Grp');
  var fieldValid = true;
  if (tstType == 'DATES')
  {
   if (begdateCntl.value == '')
   {
//       alert("!IBI.AMP.#MISSFROM;");
       alert("FROM date must be provided");
       begdateCntl.focus();
       begdateCntl.style.backgroundColor="red";
       fieldValid = false;
       return fieldValid;
   }
   if (enddateCntl.value == '')
   {
//       alert("!IBI.AMP.#MISSTO;");
       alert("TO date must be provided");
       enddateCntl.focus();
       enddateCntl.style.backgroundColor="red";
       fieldValid = false;
       return fieldValid;
   }
   if (begdateCntl.value != '' && enddateCntl.value != '' && begdateCntl.value > enddateCntl.value)
   {
//       alert("!IBI.AMP.#FROMTOERR;");
       alert("FROM Date must be less or equal to TO date");
       begdateCntl.focus();
       begdateCntl.style.backgroundColor="red";
       enddateCntl.style.backgroundColor="red";
       fieldValid = false;
       return fieldValid;
   }
  }
  if (tstType == 'CONTID')
  {
   if (contidCntl.value == '')
   {
//     alert("!IBI.AMP.#NOTNUMERIC;");
     alert("Contract Id is missing");
     contidCntl.focus();
     contidCntl.style.backgroundColor="red";
     fieldValid = false;
     return fieldValid;
    }
   }
  return fieldValid;
}


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2394 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Member
posted Hide Post
Thanks for your reply. I had tried that and that part was working. I dropped back to simpler code because the issue I have having as well is when you go back and forth between the selection options. If you put in dates, run the report works good. Then you switch to the contract option where I set the date controls to _FOC_NULL so you don't get prompted to enter the dates and the report runs correctly. The report runs ok for the contract id. The problem happens when you then select the date option after that. When the page refreshes, it has "_FOC_NULL" in the date fields. I've tried setting them to '' and ' ' and I've tried to capture the initial value on page load and set them to that, but can't seem to get it to work. It always displays _FOC_NULL.


WF 8.2.4 Windows
Mainframe
Oracle/DB2/SQL Server
App Studio
Tomcat/Servlet
 
Posts: 11 | Registered: May 23, 2004Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Below code should put a blank value to your date controls

begdateCntl.value = '';
enddateCntl.value = '';


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2394 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CASE-OPENED] Selection Required

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.