Scope issue?

Folks, I have a question on scope (or at least I think it is a scope question.
Here is what I want to do. In my game class (that manages the turns and picks a winner), I want to create either a SmartPlayer or a DumbPlayer object. Both are children of Player. My first run at this ended with a scope issue which, through your suggestions, I solved. I made some changes to the code and got past it.
(code below) I created an Interface PlayerInt which has the required methods (I know in this simple program, I don't need an Interface, but I am trying to learn about them and inheritance, and other things. ).Then I defined a Player class, and SmartPlayer and DumbPlayer. Player has the private name variable and a setter to set the name properly. In the constructor for SmartPlayer and DumbPlayer, I call setName("the name").
When I run the game, I declare Player computer and then instantiate a either a SmartPlayer or DumbPlayer object and assign it to Player. Howver, computer.name is null. I don't understand why it is not being set.
        Player computer = null;
        if (generator.nextInt(2) == 0){
              computer = new SmartPlayer();
        } else {
             computer = new DumbPlayer();
        } Thanks, in advance. Oil.
relevant code below:
public interface PlayerInt {
    public int takeTurn (int stones);
    public void setName(String theName);
    public String getName ();
public class Player implements PlayerInt {
    public String getName () {
        return name;
    public void setName (String theName) {
        name = theName;
     public int takeTurn(int stones){
         return -1;
    private String name;
public class DumbPlayer extends Player {
    public void DumbPlayer () {
        setName("Dumb Player");
* Take a random number of stones that are less than or equal to 1/2 pile.
* PlayerInt must take between 1 and 1/2 stones. At 3 or less, can only take 1 stone and comply with rules.
* @param stones this is the number of stones in the pile.
* @return returns the number of stones taken.
    public int takeTurn (int stones) {
        Random generator = new Random();
        int stonesTaken = 0;
        if (stones > 3) {
            stonesTaken = generator.nextInt((1 + stones)/2);
        } else {
            stonesTaken = 1;
        return stonesTaken;
public class SmartPlayer extends Player {
    public void SmartPlayer() {
        setName("Smart Player");
     * PlayerInt takes a turn based on rules.
     * PlayerInt takes enough stones to make the pile 1 power of 2 less than 3, 3, 7, 15, 31, or 63 and less than 1/2 the pile.
     * If the pile is already 3, 7, 15, 31, or 63, take a random stone.
     * @param stones the number of stones left in the pile.
     * @return the number of stones taken.
    public int takeTurn (int stones) {
        int halfstones = stones/2;
        int stonesToTake = 0;
        switch (stones) {
            case 1:
            case 2:
            case 3:
                stonesToTake = 1;
                break;
            case 7:
            case 15:
            case 31:
            case 63:
                Random generator = new Random();
                stonesToTake = generator.nextInt(1 + halfstones);
                break;
            default:
                if (stones > 3 && stones < 7){
                    stonesToTake = stones - 3;
                } else if (stones > 7 && stones < 15) {
                    stonesToTake = stones - 7;
                } else if (stones > 15 && stones < 31) {
                    stonesToTake = stones - 15;
                } else if (stones > 31 && stones < 63) {
                    stonesToTake = stones - 31;
                }else if (stones > 63) {
                    stonesToTake = stones - 63;
        return stonesToTake;
public class Game {
    // Let player choose to play smart vs dumb, human vs computer,
    //human vs dumb, or human vs smart.
    public void playGame() {
        Pile thePile = new Pile();
        Random generator = new Random();
        int turn = generator.nextInt(2);
        HumanPlayer human = new HumanPlayer();
        boolean foundWinner = false;
        String winner = "";
        int stonesTaken;
// declare parent
        Player computer;
// instantiate and assign a SmartPlayer or DumbPlayer object to Player reference.
        if (generator.nextInt(2) == 0){
              computer = new SmartPlayer();
        } else {
             computer = new DumbPlayer();
        if (turn == 0) {
// Should print out either "Smart Player" or "Dumb Player"
            System.out.println(computer.getName() + " took the first turn. There are " + thePile.getNumberOfStones() + " stones in the pile.");
        } else {
            System.out.println("You take the first turn. There are " + thePile.getNumberOfStones() + " stones in the pile.");
        while (!foundWinner) {
            if (turn == 0) {
                stonesTaken = computer.takeTurn(thePile.getNumberOfStones());
                thePile.takeStones(stonesTaken);
                System.out.println(computer.getName() + " took: " + stonesTaken + " stones.");
                turn = 1;
            } else {
                thePile.takeStones(human.takeTurn(thePile.getNumberOfStones()));
                turn = 0;
            if (thePile.getNumberOfStones() == 0) {
                if (turn == 0) {
                    foundWinner = true;
                    winner = human.getName();
                } else {
                    foundWinner = true;
                    winner = computer.getName();
        }// end while
        System.out.println("The winner is " + winner + ".");
}

To be honest. I'd keep both interface and abstract class.
But instead of using a reference to the abstract class use the interface instead.
So
PlayerInt player = null;
//later
player = new DumbPlayer();This is actually the "correct" way of doing this. So basically any code that uses the PlayerInt does not actually need to know what implementation is being used. In your example this is not important since you initialize it yourself but imagine you had an APIthat exposed the computer player with a method like this...
public PlayerInt getComputerPlayer()Then other code can use this method to get a PlayerInt implementation. It won't know which one, and it won't care. And that's why this is flexible and good. Because you can add new implementations later.
The Player abstract class is actually hidden away from most code as an implementation detail. It's not great to use abstract classes as reference types because if you want to create new implementations later among other things you've boxed yourself in to a class heirarchy. But abstract classes are good for refactoring away boilerplate code, as you have already done here. There's no point in implementing get/setName over and over again so do as you have here, create an abstract class and stick the basic implementation there.
Anyway all this is akin to why it is preferrable (uj slings and arrows aside) to do things like
List<String> list = new ArrayList<String>();All you care is that you have a List (interface), you don't care what implementation (ArrayList) nor do you care that there is an abstract class (or two) that ArrayList extends.

Similar Messages

  • Pulseaudio and systemd --user: DBus scope issues?

    Hi,
    I have a multi-seat setup, so I need user-wide pulseaudio and whatnot. I'm trying to setup my boot through systemd --user.
    Testing audio working apps are firefox, mpv, and mpd. The problem is:
    - If I start pulseaudio and mpd manually everything is fine (no use of systemd)
    - If I start pulseaudio through systemd no application has sound.
    - If I start pulseaudio and mpd through systemd only mpd has sound.
    raimundoyamtech~$ cat .config/systemd/user/pulseaudio.service
    [Unit]
    Description=PulseAudio Sound System
    After=sound.target
    [Service]
    ExecStart=/usr/bin/pulseaudio
    [Install]
    WantedBy=multi-user.target
    raimundoyamtech~$ cat .config/systemd/user/mpd.service
    [Unit]
    Description=Music Player Daemon
    After=network.target sound.target
    [Service]
    ExecStart=/usr/bin/mpd %h/.config/mpd/mpd.conf --no-daemon
    ExecStop=/usr/bin/mpd %h/.config/mpd/mpd.conf --kill
    Restart=always
    [Install]
    WantedBy=multi-user.target
    If I add BusName=org.pulseaudio.Server to the pulseaudio.service nothing changes.
    Using pulseaudio's autospawn=yes leads to what seems to be same behaviour: mpd by systemd starts pulseaudio and is the only app with sound.
    ./config/pulse/client.conf only contains default-sink. Everything else is default.
    Using alsa alone is not an option because of firefox.
    Any thoughts?
    EDIT:
    raimundoyamtech~$ systemctl --version
    systemd 208
    +PAM -LIBWRAP -AUDIT -SELINUX -IMA -SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ
    raimundoyamtech~$ pulseaudio --version
    pulseaudio 4.0
    Last edited by Raimundo (2013-10-23 10:08:13)

    ewaller wrote:
    Please do not bump.   I understand the frustration; really, I do.  But, these are very active forums with some very good technical people lurking about.  I guarantee your post had been read.  I read it.  I did not have an answer, as I have never seen that behavior afore.   I am certain that was true for many other regulars.
    In the future, you can bring focus to a thread by providing more information..  Tell us what you have tried, what you have read since the last post, etc.  At least it gives the impression that you are working the problem rather than merely waiting for a response.
    I don't know almost anything about systemd, especially because it changes so rapidly and documention is so scarce and outdated that either I read the whole documentantion for my version in hopes of finding my problem (something for which I do not have time) or post a topic.
    I posted everything I touched regarding systemd since the installation of my system, that's all the relevant information I know I can give, so at this point I had no more info to give.
    Actually posting a topic is really my last resort, it usually means that I have already tried everything I knew and I'm hopeless already.
    raimundoyamtech~$ loginctl list-sessions
    SESSION UID USER SEAT
    2 1002 carla seat0
    1 1000 raimundo seat0
    2 sessions listed.
    raimundoyamtech~$ loginctl show-session 1
    Id=1
    Timestamp=Tue 2013-10-29 12:33:47 WET
    TimestampMonotonic=6670234
    VTNr=1
    TTY=tty1
    Remote=no
    Service=login
    Scope=session-1.scope
    Leader=1456
    Audit=1
    Type=tty
    Class=user
    Active=no <----- Is this what you are talking about?
    State=online
    IdleHint=yes
    IdleSinceHint=1383050072367636
    IdleSinceHintMonotonic=0
    Name=raimundo
    raimundoyamtech~$ loginctl show-session 2
    Id=2
    Timestamp=Tue 2013-10-29 12:33:47 WET
    TimestampMonotonic=6667439
    VTNr=2
    TTY=tty2
    Remote=no
    Service=login
    Scope=session-2.scope
    Leader=1453
    Audit=2
    Type=tty
    Class=user
    Active=no <----- Is this what you are talking about?
    State=online
    IdleHint=yes
    IdleSinceHint=1383050025387636
    IdleSinceHintMonotonic=0
    Name=carla
    raimundoyamtech~$ loginctl show-session 3
    Failed to issue method call: No such file or directory
    What is an active session? Oo Never heard of it
    I could start things. Pulseaudio started, so did mpd. I also have a /usr/lib/systemd/systemd --user process started for each user. I assumed this would be it since this
    raimundoyamtech~$ systemctl --user
    Failed to issue method call: Process /bin/false exited with status 1
    always happens and I've read that systemctl --user is no longer required.
    [EDIT]
    Fixed it. Don't remember where I read that it wasn't required, just that it was in the same place I found someone else complaining about getting this error.
    For anyone else encountering this: sed -i s/system-auth/system-login/g /etc/pam.d/systemd-user
    and systemctl --user will work. Insults fly out to the one who wrote it wasn't required!
    Still am not able to get an active session though
    [/EDIT]
    Why would there be a need for anything else? I'm gonna check on that. Thanks!
    See, the bump worked ^^ but ok I'll try to refrain from doing that next time. Sorry.
    Last edited by Raimundo (2013-10-29 16:27:55)

  • Variable scope issue - EWS

    Hi everyone,
    So I have a funny issue. From line 8 to line 37 I declare a set of variables, most of them with null values. Then I call a function: SetupEWSAndFolder (line 88) which sets a lot of these variables. Once the function exits, the variables are empty.
    How come ? I thought that variables defined at script level would be updated in child functions ? Is it because of the null value ? I have another script with the same kind of setup but the variables are not set to null and it works perfectly fine.
    And for the fun, i tested echoing the value at the end of the function of some variables and then outside and the one outside are not updated
    I also tested using: $global:mb for instance, I still have the initial value set in the script and not the one updated in the function
    Thanks for helping me clear up my misunderstanding of the issue
    Olivier
    # Using Export - Import would be easier but since we do not have the rights for it and it requires a specific role being assigned to us... here goes EWS!!!
    # Include the Exchange Web Service DLL
    Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll"
    # Import the logwrite ability
    . .\LogWrite.ps1
    ################################################### INITIAL VARIABLES SETUP ###################################################
    #Setting up the log file
    #$userLogon = $args[0]
    $userLogon = "olivraga"
    $Logfile = "$userLogon.log"
    #setting up the name of the top folder in which to transfer #Inbox#, #SentItems#, #DeletedItems#
    $folderName = "_AutoOffBoardingArchiveFolder"
    #get the current username
    $credUserName = Get-Content env:username
    #Setting the mailbox variable for the folder binds in EWS
    $mailbox = $null
    #Setting up the Exchange Web Services connection
    $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion)
    $mb = $null
    #Setting up the folder variables for general calls
    $rootFolderID = $null
    $topFolder = $null
    $iFolder = $null
    $dFolder = $null
    $sFolder = $null
    #Setting up the folder ID to the targetted mailbox
    #(otherwise we would target the mailbox of the current account which we do not want :))
    $inboxID = $null
    $deletedItemsID = $null
    $sentItemsID = $null
    #Setting up the #Inbox# , #SentItems# , #DeletedItems# folder variables
    $inbox = $null
    $deletedItems = $null
    $sentItems = $null
    ############################ Function that moves a folder to another folder, including sub folders ############################
    function MoveItems(){
    $source, $dest, $path = $args[0]
    LogWrite "Copying/Moving $path"
    #Pulls items by thousands at a time
    $ivItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
    $fiItems = $null
    do{
    #Get the 1000 items present in the source folder
    $fiItems = $service.FindItems($source.Id,$ivItemView)
    foreach($Item in $fiItems.Items){
    # Copy the Message
    $Item.Copy($dest.Id) | out-null
    # If you want to switch to a move instead use:
    #$Item.Move($dest.Id)
    $ivItemView.Offset += $fiItems.Items.Count
    }while($fiItems.MoreAvailable -eq $true)
    #Do the subfolders now
    if ($source.ChildFolderCount -gt 0)
    # Deal with any subfolders first
    $folderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
    $foldersFound = $source.FindFolders($folderView)
    ForEach ($subFolder in $foldersFound.Folders)
    $subFolderToCreate = New-Object Microsoft.Exchange.WebServices.Data.Folder($service)
    $subFolderToCreate.DisplayName = $subFolder.DisplayName
    $subFolderToCreate.Save($dest.Id)
    MoveItems($subFolder, $subFolderToCreate, $path+"\"+$subFolder.DisplayName)
    ################################# Initial necessary setup like full access and EWS connection #################################
    function SetupEWSAndFolder(){
    $mailbox = (Get-ADUser $userLogon -Properties mail).mail
    # Giving the current account Full Access to the Mailbox
    Add-MailboxPermission -Identity $mailbox -User $credUserName -AccessRights FullAccess -InheritanceType All -Confirm:$false
    $service.Url = "https://webmail.brookfieldrenewable.com/EWS/Exchange.asmx"
    #$service.Credentials = new-object Microsoft.Exchange.WebServices.Data.WebCredentials($userLogon,$userPassword,"hydro")
    #$service.Credentials = $creds.GetNetworkCredential()
    $service.UseDefaultCredentials = $true
    $service.AutodiscoverUrl($mailbox)
    $mb = new-object Microsoft.Exchange.WebServices.Data.Mailbox("$mailbox")
    #Get the root folder ID of the targetted mailbox
    $rootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::msgfolderroot, $mb)
    #Create new top folder to contain the Inbox, DeletedItems and SentItems folder
    $topFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $topFolder.DisplayName = "$folderName"
    $topFolder.Save($rootFolderID)
    #Create the subfolders to the topFolder to copy or move the emails in #Inbox# , #SentItems# , #DeletedItems#
    $iFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $iFolder.DisplayName = "Inbox"
    $iFolder.Save($topFolder.Id)
    $sFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $sFolder.DisplayName = "SentItems"
    $sFolder.Save($topFolder.Id)
    $dFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $dFolder.DisplayName = "DeletedItems"
    $dFolder.Save($topFolder.Id)
    #Just to make sure that the folder is created and everything is updated nicely
    Start-Sleep 5
    $inboxID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$mb)
    $deletedItemsID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::DeletedItems,$mb)
    $sentItemsID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::SentItems,$mb)
    $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $inboxID )
    $deletedItems = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $deletedItemsID)
    $sentItems = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $sentItemsID)
    SetupEWSAndFolder #setup the EWS connections and the folders
    MoveItems ($inbox, $iFolder, "Inbox") #Copy (not move yet) Inbox to the archive folder
    MoveItems ($deletedItems, $dFolder, "DeletedItems") #Same but for deleted items
    MoveItems ($sentItems, $sFolder, "SentItems") #Same but for sent items
    ##################################################### Helper Code Blocks ######################################################
    <#
    #Block of code in case one does not know the ID of the folder, but since we just created the topFolder, we do not need to search for it :)
    #Bind to the MSGFolder Root
    $rootFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,"hydro\$userLogon")
    #Setup the retrieval of the folder ID just created
    $targetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$rootFolderId)
    $searchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$folderName)
    $folderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
    $findFolderResults = $service.FindFolders($rootFolderId, $searchFilter, $folderView)
    #>

    When you read the about_scope you see:
            - An item you include in a scope is visible in the scope in which it
              was created and in any child scope, unless you explicitly make it
              private. You can place variables, aliases, functions, or Windows
              PowerShell drives in one or more scopes.
    To me, it means that if you define a variable at the script level, it is going to be availble at the function level. To me, the function scope level is a child of the script scope level.
    So I did a check and it works like you say. But it is annoying, look at the following script and result:
    #This is a scope test:
    $nbErrors = "script";
    Function DoErrorTest(){
    $nbErrors
    $nbErrors = "inside"
    $nbErrors
    DoErrorTest
    $nbErrors
    Result:
    script
    inside
    script
    Which logical and totally annoying at the same time. And, to me, it means that you can never assign a value in a child scope by using the name of the variable. But you can display the value of the parent scope variable as long as you don't give a value to
    a same name variable in a child scope....
    This is gonna be annoying...
    Thanks

  • NI SCOPE issues with program

    I originally had a program that used cursors on a pulse signal to calculate the average of two different gates, and find the difference between them. It worked at one point when I was using the NI SCOPE express VI, but when I tried switching to the real NI SCOPE using Multi Record, due to efficiency issues, I ran into some bugs that I need some help with. The main issue is that one of the pair of gates(cursors) is not getting averaged, but the first one is. Because of this, the program will not find the difference.The issue may be because I had to switch from using a signal to using a waveform with the property node. If anyone could provide any sort of assistance, that would be great!
    Attachments:
    NewPulse.vi ‏54 KB

    I think you are simply missing a wire
    Jeff

  • Scope issue: Trying to set the value of a variable in a calling (upper) script from a called (lower) script

    Hi,
    I have a basic scope question . I have two .ksh scripts. One calls the other.
    I have a variable I define in script_one.ksh called var1.
    I set it equal to 1. so export var1=1
    I then call script_two,ksh from script_one.ksh.  In script_two.ksh I set the value of var1 to 2 . so var1=2.
    I return to script_one.ksh and echo out var1 and it still is equal to 1.
    How can I change the value of var1 in script_two.ksh to 2 and have that change reflected in script_one.ksh when I echo var1 out after returning from script_two.ksh.
    I've remember seeing this I just can't remember how to do it.
    Thanks in advance.

    Unfortunately Unix or Linux does not have a concept of dynamic system kernel or global variables.
    Environment variables can be exported from a parent to a child processes, similar to copying, but a child process cannot change the shell environment of its parent process.
    However, there are a few ways you could use: You can source execute the scripts, using the Bash source command or by typing . space filename. When source executing a script, the content of the script are run in the current shell, similar to typing the commands at the command prompt.
    Use shell functions instead of forking shell scripts.
    Store the output of a script into a variable. For instance:
    #test1.sh
    var=goodbye
    echo $var
    #test2.sh
    var=hello
    echo $var
    var=`./test1.sh`
    echo $var
    $ ./test2.sh
    hello
    goodbye

  • JSP - Bean - Scope Issue with ResultSet

    Hi there,
    I have a JSP page that uses a Bean to get ResultSets from a db. My methods return ResultSets, but they seem to get out of scope on the JSP page when I try to use them. I'm not sure why. I have included 2 snippets below one that works and one that doesn't. I get a java.lang.null exception when the page is run. Not sure how or why the variable seems to go out of scope? I can work around it, but I would rather find out why this is happening.
    This one fails:
    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    try{
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <%
    ResultSet roem = lookup.getOEMDropdown();
    //open db conn
    lookup.openIlprod();
    if(roem!=null){
    %>
    OEM:  
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){     
         //log to Tomcat
    %>
    This one works....why??
    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    try{
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <%
    //open db conn
    lookup.openIlprod();
    ResultSet roem = lookup.getOEMDropdown();
    if(roem!=null){
    %>
    OEM:  
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){     
         //log to Tomcat
    %>

    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    String ilprod_db_user;
    String ilprod_db_pass;
    String tedsi_prod_owner;
    String nsp_portal_owner;
    String iladmin_owner;
    String ilprod_db_host;
    String ilprod_db_port;
    String ilprod_db_service;
    try{
         //get the ilprod_db_user from the deployment descriptor
         ilprod_db_user = (String)getServletContext().getInitParameter("ilprod_db_user");
         //ensure a value is present
         if(ilprod_db_user==null||ilprod_db_user.equals("")){
         throw new ServletException("Error retrieving ilprod_db_user from deployment descriptor. - ilprod_db_user is null or an empty string");
         //get the ilprod_db_pass from the deployment descriptor
         ilprod_db_pass = (String)getServletContext().getInitParameter("ilprod_db_pass");
         //ensure a value is present
         if(ilprod_db_pass==null||ilprod_db_pass.equals("")){
         throw new ServletException("Error retrieving ilprod_db_pass from deployment descriptor. - ilprod_db_pass is null or an empty string");
         //get the tedsi_prod_owner from the deployment descriptor
         tedsi_prod_owner = (String)getServletContext().getInitParameter("tedsi_prod_owner");
         //ensure a value is present
         if(tedsi_prod_owner==null||tedsi_prod_owner.equals("")){
         throw new ServletException("Error retrieving tedsi_prod_owner from deployment descriptor. - tedsi_prod_owner is null or an empty string");
         //get the nsp_portal_owner from the deployment descriptor
         nsp_portal_owner = (String)getServletContext().getInitParameter("nsp_portal_owner");
         //ensure a value is present
         if(nsp_portal_owner==null||nsp_portal_owner.equals("")){
         throw new ServletException("Error retrieving nsp_portal_owner from deployment descriptor. - nsp_portal_owner is null or an empty string");
         //get the iladmin_owner from the deployment descriptor
         iladmin_owner = (String)getServletContext().getInitParameter("iladmin_owner");
         //ensure a value is present
         if(iladmin_owner==null||iladmin_owner.equals("")){
         throw new ServletException("Error retrieving iladmin_owner from deployment descriptor. - iladmin_owner is null or an empty string");
         //get the ilprod_db_host from the deployment descriptor
         ilprod_db_host = (String)getServletContext().getInitParameter("ilprod_db_host");
         //ensure a value is present
         if(ilprod_db_host==null||ilprod_db_host.equals("")){
         throw new ServletException("Error retrieving ilprod_db_host from deployment descriptor. - ilprod_db_host is null or an empty string");
         //get the ilprod_db_port from the deployment descriptor
         ilprod_db_port = (String)getServletContext().getInitParameter("ilprod_db_port");
         //ensure a value is present
         if(ilprod_db_port==null||ilprod_db_port.equals("")){
         throw new ServletException("Error retrieving ilprod_db_port from deployment descriptor. - ilprod_db_port is null or an empty string");
         //get the ilprod_db_service from the deployment descriptor
         ilprod_db_service = (String)getServletContext().getInitParameter("ilprod_db_service");
         //ensure a value is present
         if(ilprod_db_service==null||ilprod_db_service.equals("")){
         throw new ServletException("Error retrieving ilprod_db_service from deployment descriptor. - ilprod_db_service is null or an empty string");
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <jsp:setProperty name="lookup" property="ilprod_db_user" value="<%=ilprod_db_user%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_pass" value="<%=ilprod_db_pass%>"/>
    <jsp:setProperty name="lookup" property="tedsi_prod_owner" value="<%=tedsi_prod_owner%>"/>
    <jsp:setProperty name="lookup" property="nsp_portal_owner" value="<%=nsp_portal_owner%>"/>
    <jsp:setProperty name="lookup" property="iladmin_owner" value="<%=iladmin_owner%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_host" value="<%=ilprod_db_host%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_port" value="<%=ilprod_db_port%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_service" value="<%=ilprod_db_service%>"/>
    <%
    //open db conn
    lookup.openIlprod();
    ResultSet roem = lookup.getOEMDropdown();
    ResultSet rstat = lookup.getStatusDropdown();
    if(roem!=null){
    %>
    OEM:��
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    //******* IF I PUT ResultSet IN FRONT OF rstat HERE IT WORKS FINE?
    rstat = lookup.getStatusDropdown();
    if(rstat!=null){
    %>
    Status:��
    <select name="status">
    <%
    while(rstat.next()){
    %>
    <option value="<%=rstat.getString("id")%>"><%=rstat.getString("description")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("Status:  no records<br><br>");
    //close db conn
    lookup.closeIlprod();
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){
         //set request attributes to pass to error page
         request.setAttribute("javax.servlet.error.exception",e);
         request.setAttribute("javax.servlet.error.message",e.getMessage());
         request.setAttribute("javax.servlet.error.request_uri",     request.getRequestURI());
         request.setAttribute("javax.servlet.error.servlet_name", request.getServletPath());
         //log to Tomcat
         application.log(" Message: "+e.getMessage()+'\r'+'\n'+"RequestURI: "+request.getRequestURI()+'\r'+'\n'+"Servlet Path: "+request.getServletPath(),e);
         //forward to the error page
         RequestDispatcher rd =     request.getRequestDispatcher("error.jsp");
         rd.forward(request,response);
         //out.println(e.getMessage());
    %>

  • Flex/Actionscript External XML Scope Issue

    I am processing an external XML file in an event listener
    after the URLLoader is complete. The issue I'm having is that I
    want getProduct() to return the XML data. How can I get the data
    from the event listener getXML(). I tried creating a public
    variable outside of the functions but I can't access it from within
    the two functions.
    package messages
    import flash.events.Event;
    import flash.net.*;
    //Returns the current product
    public class FetchXMLData
    public static function getXML(e:Event):void {
    var myProduct:XML = new XML(e.target.data);
    trace(myProduct.product);
    public static function getProduct():XML{
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE,
    FetchXMLData.getXML);
    loader.load(new URLRequest("
    http://www.example.com/api"));
    var myProducts:XML = new XML();
    //get the value from the listener?!
    return myProducts;
    }

    I'm also running into this problem.  I'm running on Eclipse 3.4 w/ the WBEJ_plugin 3.2.
    Everyon else using this application isn't have a problem saving and the encoder doesn't mess up their SOAP requests, but each time I send, SOAP double-encodes the &, resulting in the error you described.  The problem I was running into was then dealing w/ that XML on a return SOAP, where I'm expecting well formed XML, and instead I get &amplt;WhateverName&gt;, which Flex reinterprets as &lt;, and not <.  I made an ugly hack for that that will just split/join any of those, but if there is a real reason why this is happening, that would be great to find out.

  • WLC dhcp scope issue

    Hi,
    We are facing this problem
    we are using guest SSID with captive portal authentication.
    We are using below step to conect to network
    1) User will click on guest SSID & get IP from DHCP scope
    2) User will open google.com & then it will redirect to authentication page - we need to provide userid/pass & then we will able to access internet
    Problem
    Assume user only do Step -1 , Then My dhcp scope is utilizing
    How can we restrict the same to 'geneuine' user, any option/workaround ?
    br/subhojit

    I have to agree with e. Shortening theeaae will help.
    But the kny way to keep people off the WLAN would be to use a PSK so that only authorized users can get on.
    HTH
    Steve

  • RemoteObject Scope Issue

    I posted this in the ColdFusion forums earlier, but figured it might actually be better here in the Flex forums, so sorry for the repost.
    I am trying to create a backend for an AIR application. The application is a poker site. I can return objects from ColdFusion to AIR just fine, but the problem is, everytime I make a call to a function in my CFC, it acts as if each call is a seperate "instance" of the CFC.
    Below is the CFC I am using...
    <cfcomponent output="false" name="Deck">
    <cfset suits = ["hearts", "diamonds", "spades", "clubs"]>
    <cfset cards = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]>
    <cfset names = ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"]>
    <cfset deck = ArrayNew(1)>
    <cffunction name="CreateDeck" access="remote">
    <cfscript>ArrayClear(deck);</cfscript>
    <cfset cardsLength = ArrayLen(cards)/>
    <cfset suitsLength = ArrayLen(suits)/>
    <cfloop index="i" from="1" to=#suitsLength#>
    <cfloop index="j" from="1" to=#cardsLength#>
    <cfscript>
    ArrayAppend(deck, [cards[j],suits[i]]);
    </cfscript>
    </cfloop>
    </cfloop>
    <cfscript>ShuffleDeck();</cfscript>
    <cfreturn deck />
    </cffunction>
    <cffunction name="ShuffleDeck">
    <cfset CreateObject("java","java.util.Collections").Shuffle(deck)/>
    </cffunction>
    <cffunction name="DealCard" access="remote">
    <cfset randomNumber = RandRange(1, ArrayLen(deck), "SHA1PRNG")/>
    <cfreturn ArrayLen(deck)/>
    </cffunction>
    </cfcomponent>
    Below is a sample of the Flex code I am using to call the CFC...
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      creationComplete="initApp()">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <s:RemoteObject id="svc" destination="ColdFusion" endpoint="http://localhost:8500/flex2gateway/" source="PokerSite.cfc.Deck">
    <s:method name="CreateDeck" result="resultHandler(event)" fault="faultHandler(event)"/>
    <s:method name="DealCard" result="resultHandler(event)" fault="faultHandler(event)"/>
    </s:RemoteObject>
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    private function initApp():void
    svc.CreateDeck();
    private function doDeal():void
    svc.DealCard();
    private function resultHandler(e:ResultEvent):void
    trace(e.result);
    private function faultHandler(e:FaultEvent):void
    trace(e.fault);
    ]]>
    </fx:Script>
    <s:Panel x="0" y="0" width="250" height="200">
    <s:Button click="doDeal()" label="Deal"/>
    </s:Panel>
    </s:WindowedApplication>
    When I call the CreateDeck() function of the CFC, it returns the entire deck just fine. However, when I then call the DealCard() function by clicking the button, it returns a length of 0 of the deck object in the CFC (just returning the length to test that the deck has been created for now) as if the deck was never created. I did some searching online, and found that I might have to setup the remoting-config.xml file to allow application level scope. I then setup the remoting-config.xml like so...
    <destination id="ColdFusion">
    <channels>
    <channel ref="my-cfamf"/>
    </channels>
    <properties>
    <source>*</source>
    <scope>application</scope>
    </properties>
    </destination>
    Yet, this still fails the same way. Does anyone know if I am missing a simple step? Or setting up the application scope in the wrong place? It definitely sounds like the problem I am having, but when I change that remoting-config.xml file, it doesn't seem to change anything in the way the functions are called.

    Anyone have any idea for this?

  • Custom Event Scope Issue?

    I think I need I might need to create an Event member for the
    Dispatching Object, but am not sure. Any idea what's missing from
    the example code below?
    Base Class:
    import flash.events.*;
    private function init():void
    _Data = new Data();
    _Data.addEventListener(Data.DATA_INIT, dataInit);
    private function dataInit(e:Event):void
    trace('dataReceived');
    Object Class:
    import flash.events.*;
    public class Data extends EventDispatcher
    public static const DATA_INIT:String = "DATA_INIT";
    private function someFunction()
    dispatchEvent(new Event(Data.DATA_INIT));
    }

    I am having virtually the same problem with event dispatch. I
    know what the problem seems to be (though it makes no sense), but I
    don't know of a good workaround.
    If events are dispatched from a static class or from the base
    class, they never get beyond the target phase, so they are never
    propagated out of the scope of the class.
    I suppose that you could instantiate a singleton, and
    dispatch your events from that using a method call, but that seems
    REALLY kludgy. Does anyone know of a better solution?

  • BackingBean Scope issue.

    Hi,
    I am using JdEV 11.1.1.2.0. I have an ADF table on the page with 100 records and rangsize is set to 25.
    On the page i have one button to get the selected row and call the procedure.
    If I select a 50th record in 100 records and click on button, I am getting the following added exception in the server log. But this issue is not reproducing if I select a record with in rangesize i.e. 25.
    These are my viewObject Tuning properties:
    All rows.
    Fill Last Page of rows when paging throw Rowset.
    Passivate State
    Access Mode: Scrollable.
    Please help me to fix this issue.
    Server Log:
    <UIXPageTemplate><tearDownVisitingContext> Tear down of page template context failed due to an unhandled exception.
    java.util.NoSuchElementException
         at java.util.ArrayDeque.removeFirst(ArrayDeque.java:251)
         at java.util.ArrayDeque.pop(ArrayDeque.java:480)
         at oracle.adfinternal.view.faces.context.ApplicationContextManagerImpl.popContextChange(ApplicationContextManagerImpl.java:66)
         at oracle.adf.view.rich.component.fragment.UIXPageTemplate.tearDownVisitingContext(UIXPageTemplate.java:242)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.encodeEnd(ContextSwitchingComponent.java:157)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:415)
         at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:2572)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:432)
         at oracle.adfinternal.view.faces.renderkit.rich.FormRenderer.encodeAll(FormRenderer.java:221)
         at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1369)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:751)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:415)
         at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:2572)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:432)
    <Dec 21, 2009 3:58:35 PM MST> <Error> <HTTP> <BEA-101020> <[ServletContext@4711920[app:ESPSApp module:ESPSApp-ViewController-context-root path:/ESPSApp-ViewController-context-root spec-version:2.5 version:V2.0]] Servlet failed with Exception
    java.lang.NullPointerException
         at oracle.adfinternal.view.faces.model.binding.RowDataManager.getRowIndex(RowDataManager.java:189)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.getRowIndex(FacesCtrlHierBinding.java:596)
         at org.apache.myfaces.trinidad.component.UIXIterator._fixupFirst(UIXIterator.java:414)
         at org.apache.myfaces.trinidad.component.UIXIterator.__encodeBegin(UIXIterator.java:392)
         at org.apache.myfaces.trinidad.component.UIXTable.__encodeBegin(UIXTable.java:168)
         Truncated. see log file for complete stacktrace
    >
    <Dec 21, 2009 3:58:35 PM MST> <Notice> <Diagnostics> <BEA-320068> <Watch 'UncheckedException' with severity 'Notice' on server 'DefaultServer' has triggered at Dec 21, 2009 3:58:35 PM MST. Notification details:
    WatchRuleType: Log
    WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802'))
    WatchData: DATE = Dec 21, 2009 3:58:35 PM MST SERVER = DefaultServer MESSAGE = [ServletContext@4711920[app:ESPSApp module:ESPSApp-ViewController-context-root path:/ESPSApp-ViewController-context-root spec-version:2.5 version:V2.0]] Servlet failed with Exception
    java.lang.NullPointerException
         at oracle.adfinternal.view.faces.model.binding.RowDataManager.getRowIndex(RowDataManager.java:189)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.getRowIndex(FacesCtrlHierBinding.java:596)
         at org.apache.myfaces.trinidad.component.UIXIterator._fixupFirst(UIXIterator.java:414)
         at org.apache.myfaces.trinidad.component.UIXIterator.__encodeBegin(UIXIterator.java:392)
         at org.apache.myfaces.trinidad.component.UIXTable.__encodeBegin(UIXTable.java:168)
         at org.apache.myfaces.trinidad.component.UIXCollection.encodeBegin(UIXCollection.java:517)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:399)
         at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:2572)
         at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:432)
    Thanks.

    Hi,
    Thanks for your reply.. Please find the source code:
    Table Code:
    <af:table value="#{bindings.CmProcessView35.collectionModel}"
    var="row"
    rows="#{bindings.CmProcessView35.rangeSize}"
    emptyText="#{bindings.CmProcessView35.viewable ? 'No data to display.' : 'Access Denied.'}"
    fetchSize="#{bindings.CmProcessView35.rangeSize}"
    rowBandingInterval="0"
    selectedRowKeys="#{bindings.CmProcessView35.collectionModel.selectedRow}"
    selectionListener="#{bindings.CmProcessView35.collectionModel.makeCurrent}"
    rowSelection="single"
    binding="#{backingBeanScope.backing_app_RunCalcPage.t4}"
    id="t4" inlineStyle="height:400px;" width="510" partialTriggers="::q1">
    <af:column sortProperty="ProcessType" sortable="true"
    headerText="#{bindings.CmProcessView35.hints.ProcessType.label}"
    id="c19">
    <af:outputText value="#{row.ProcessType}" id="ot19"/>
    </af:column>
    <af:column sortProperty="Description" sortable="true"
    headerText="#{bindings.CmProcessView35.hints.Description.label}"
    id="c17" width="300">
    <af:outputText value="#{row.Description}" id="ot8"/>
    </af:column>
    <af:column sortProperty="ArgumentsFlag" sortable="true"
    headerText="P - Flag"
    id="c18" width="70">
    <af:outputText value="#{row.ArgumentsFlag}" id="ot20"/>
    </af:column>
    </af:table>
    Page Def Code:
    <iterator Binds="CmProcessView3" RangeSize="25"
    DataControl="ESPSAppModuleDataControl"
    id="CmProcessView3Iterator"/>
    BackingBean Code:
    RowKeySet rowKeySet = (RowKeySet)this.t4.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.t4.getValue();
    String process = null;
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData =
    (JUCtrlHierNodeBinding)cm.getRowData();
    process = rowData.getAttribute(0).toString();
    if (process != null) {
    System.out.println("activeFlag is : " + activeFlag);
    if(activeFlag.equals("N")){
    ---------- Perform some operations...
    }else{                   
    sendMessage("Process Selection is Invalid.", FacesMessage.SEVERITY_ERROR);
    }else{               
    sendMessage("Please select a process to submit the job.", FacesMessage.SEVERITY_ERROR);
    Thanks.

  • Paint component scope issues

    hi i have 2 classes one is my main and the other is the paint class with void paintcomponent() inside
    how do i pass the x variable inside main class so i can use it inside the Map class
    i know you can use scope e.g. Map map = new Map(x,y); but then i have to use a constructor with
    its own repaint(); method inside but it does not work.
    i was thinking of overloading a constructor aswell so inside one constructor is nothing and in the other with the (x, y) has
    the repaint method inside but that doesn't work either.
    main class
    public class Main
    public static void main(String[] args) {
    MainFrame frame = new MainFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(500, 500);
    frame.setVisible(true);
    class MainFrame extends JFrame
    private int x;
    private int y;
    // map class with paint component
    Map map = new Map(x,y);
    public MainFrame(){
    this.add(map);
    }paint class
    public class Map extends JPanel {
    private int x;
    private int y;
    public Map(){}
    public Map(int x, int y){
    this.x = x;
    this.y = y;
    repaint();
        @Override
        public void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }this does not work, any ideas?
    Edited by: nicchick on Nov 25, 2008 1:00 AM

    um that wasnt exactly what i was looking for i have a better example
    what im trying to do is pass/scope private varibles from the main class to the map class
    but since you use repaint(); to call the paintcomponent override method theres no way to scope varibles like
    x and y to panel?
    this example shows what im trying to do with a mouselistener
    main
    public class Main
    public static void main(String[] args) {
    MainFrame frame = new MainFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(500, 500);
    frame.setVisible(true);
    class MainFrame extends JFrame
    private int x;
    private int y;
    // map class with paint component
    Map map = new Map();
    // handler
    HandlerMotion handler = new HandlerMotion();
    public MainFrame(){
    this.add(map);
    map.addMouseMotionListener(handler);
         private class HandlerMotion implements MouseMotionListener
            public void mouseDragged(MouseEvent e) {
            public void mouseMoved(MouseEvent e) {
            x = e.getX();
            y = e.getY();
            new Map(x,y);
            repaint();
    }map
    public class Map extends JPanel {
        private int x;
        private int y;
        public Map(){}
        public Map(int x, int y)
        this.x = x;
        this.y = y;
        System.out.println("this is map" + x);
        System.out.println("this is map" + y);
        repaint();
        @Override
        public void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.drawLine(0, 0, x, y);
        System.out.println("this is panel" + x);
        System.out.println("this is panel" + y);
    }

  • Targeting A MovieClip on the main Stage....Scope Issue

    main stage------>MC1------>MC2
    on MC2's timeline I want to target objects on the main stage. Not sure on how to write that without using root. I've been trying deviations of
    MovieClip(parent).MovieClip(parent).mcName.
    Thanks

    Why can't you just use root?
    And you can just put your code in the main timeline as suggested - just dispatch an event when you want your code to run and listen for it.
    So, in your clip, on whatever frame do something like:
    dispatchEvent(new Event("runMyAnim"));
    And in the main timeline:
    someClip.someClip.addEventListener("runMyAnim", runIt, false, 0, true);
    function runIt(e:Event){
         //your code goes here

  • [JS CS4/CS5] ScriptUI Click Event Issue in JSXBIN

    Still working on a huge ScriptUI project, I discovered a weird issue which appears to *only* affect 'binary compiled' scripts (JSXBIN export), not the original script!
    When you repeatedly use addEventListener() with the same event type, you theorically have the possibility to attach several handlers to the same component and event, which can be really useful in a complex framework:
    // Declare a 'click' manager on myWidget (at this point of the code)
    myWidget.addEventListener('click', eventHandler1);
    // Add another 'click' manager (for the same widget)
    myWidget.addEventListener('click', eventHandler2);
    When you do this, both eventHandler1 and eventHandler2 are registered, and when the user clicks on myWidget, each handler is called back.
    The following script shows that this perfectly works in ID CS4 and CS5:
    // Create a dialog UI
    var     u,
         w = new Window('dialog'),
         p = w.add('panel'),
         g = p.add('group'),
         e1 = p.add('statictext'),
         e2 = p.add('statictext');
    // Set some widget properties
    e1.characters = e2.characters = 30;
    g.minimumSize = [50,50];
    var gx = g.graphics;
    gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
    // g->click Listener #1
    g.addEventListener('click', function(ev)
         e1.text = 'click handler 1';
    // g->click Listener #2
    g.addEventListener('click', function(ev)
         e2.text = 'click handler 2';
    w.show();
    The result is that when you click on the group box, e1.text AND e2.text are updated.
    But now, if I export the above code as a JSXBIN from the ESTK, the 2nd event handler sounds to be ignored! When I test the 'compiled' script and click on the group box, only e1.text is updated. (Tested in ID CS4 and CS5, Win32.)
    By studying the JSXBIN code as precisely as possible, I didn't find anything wrong in the encryption. Each addEventListener() statement is properly encoded, with its own function handler, nothing is ignored. Hence I don't believe that the JSXBIN code is defective by itself, so I suppose that the ExtendScript/ScriptUI engine behaves differently when interpreting a JSXBIN... Does anyone have an explanation?
    @+
    Marc

    John Hawkinson wrote:
    Not an explanation, but of course we know that in JSXBIN you can't use the .toSource() method on functions.
    So the implication here is that perhaps the .toSource() is somehow implicated in event handlers and there's some kind of static workaround for it?
    Perhaps you can get around this by eval() or doScript()-ing strings?
    Thanks a lot, John, I'm convinced you're on the good track. Dirk Becker suggested me that this is an "engine scope" issue and Martinho da Gloria emailed me another solution —which also works— and joins Dirk's assumption.
    Following is the result of the various tests I did from your various suggestions:
    // #1 - THE INITIAL PROBLEM// =====================================
    // EVALUATED BINARY CODE
    var handler1 = function(ev)
         ev.target.parent.children[1].text = 'handler 1';
    var handler2 = function(ev)
         ev.target.parent.children[2].text = 'handler 2';
    var     u,
         w = new Window('dialog'),
         p = w.add('panel'),
         g = p.add('group'),
         e1 = p.add('statictext'),
         e2 = p.add('statictext');
    e1.characters = e2.characters = 30;
    g.minimumSize = [50,50];
    var gx = g.graphics;
    gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
    g.addEventListener('click', handler1);
    g.addEventListener('click', handler2);
    w.show();
    eval("@JSXBIN@[email protected]@MyBbyBn0AKJAnASzIjIjBjOjEjMjFjShRByBNyBnA . . . . .");
    // RESULT
    // handler 1 only, that's the issue!
    Now to John's approach:
    // #2 - JOHN'S TRICK
    // =====================================
    var handler1 = function(ev)
         ev.target.parent.children[1].text = 'handler 1';
    var handler2 = function(ev)
         ev.target.parent.children[2].text = 'handler 2';
    // EVALUATED BINARY CODE
    var     u,
         w = new Window('dialog'),
         p = w.add('panel'),
         g = p.add('group'),
         e1 = p.add('statictext'),
         e2 = p.add('statictext');
    e1.characters = e2.characters = 30;
    g.minimumSize = [50,50];
    var gx = g.graphics;
    gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
    g.addEventListener('click', handler1);
    g.addEventListener('click', handler2);
    w.show();
    eval("@JSXBIN@[email protected]@MyBbyBn0AIbCn0AFJDnA . . . . .");
    // RESULT
    // handler1 + handler2 OK!
    This test shows that if handler1 and handler2's bodies are removed from the binary, the script works. Note that the handlers are declared vars that refer to (anonymous) function expressions. (BTW, no need to use a non-main #targetengine.) This is not a definitive workaround, of course, because I also want to hide handlers code...
    Meanwhile, Martinho suggested me an interesting approach in using 'regular' function declarations:
    // #3 - MARTINHO'S TRICK
    // =====================================
    // EVALUATED BINARY CODE
    function handler1(ev)
         ev.target.parent.children[1].text = 'handler 1';
    function handler2(ev)
         ev.target.parent.children[2].text = 'handler 2';
    var     u,
         w = new Window('dialog'),
         p = w.add('panel'),
         g = p.add('group'),
         e1 = p.add('statictext'),
         e2 = p.add('statictext');
    e1.characters = e2.characters = 30;
    g.minimumSize = [50,50];
    var gx = g.graphics;
    gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
    g.addEventListener('click', handler1);
    g.addEventListener('click', handler2);
    w.show();
    eval("@JSXBIN@[email protected]@MyBbyBnACMAbyBn0ABJCnA . . . . .");
    // RESULT
    // handler1 + handler2 OK!
    In the above test the entire code is binary-encoded, and the script works. What's the difference? It relies on function declarations rather than function expressions. As we know, function declarations and function expressions are not treated the same way by the interpreter. I suppose that function declarations are stored at a very persistent level... But I don't really understand what happens under the hood.
    (Note that I also tried to use function expressions in global variables, but this gave the original result...)
    Thanks to John, Dirk, and Martinho for the tracks you've cleared. As my library components cannot use neither the global scope nor direct function declarations my problem is not solved, but you have revealed the root of my troubles.
    @+
    Marc

  • Content scope document library does not return result for non farm administrator

    Hi
    I have a situation where I had to go with a unique permission applied subsite to store 1000 documents in the document library. This site has a set of 50 users. I was able to create content scope and library path for search. It returns results for me(creator/owner/administrator)
    however if I add other users as contributor or full permission, even after full crawling it does not return result for others.
    I saw some article that security broken site wont be indexed normal way and to include and I did that as well but no result for other users. I always get result.
    Please suggest if there are any specific security permissions that I need to include, so the document library target search will return result for others.
    Thanks
    Shri

    Hi Shri,
    For administrator search results, it looks like the documents could be crawled and searched.
    For other users you grant full control permission on subsite with unique permission where you store 1000 dcouments in document library, please make sure these 50 users have access permission(at least view permission) on documents from the
    library, then test again.
    Also test if users search on search center site without search scope, see if it's scope issue or search web part issue.
    If above doesn't work, please check ULS log for related useful information around the time when users search the documents, there should be more info to verify if issue is related to unique permision.
    Thanks,
    Daniel Yang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for