Why this line of code returns null always??

Dear All,
Just a question.
I have this snippet of code where a user is required to input a number.
<af:panelGroupLayout layout="vertical" id="pgl1">
  <af:inputText label="number" id="it1"
                    value="#{MyBean.number}" immediate="true"/>
  <af:commandButton text="Submit" id="cb1" partialSubmit="true"
                    immediate="true"
                    actionListener="#{MyBean.handleAction}"/>
</af:panelGroupLayout>The immediate attribute at both inputtext and button are needed as I am bypassing validation on the other form components.
Here is my bean defined in request scope.
public class MyBean
  private String number;
  public void handleAction(ActionEvent actionEvent)
    AdfFacesContext ctx = AdfFacesContext.getCurrentInstance();
    Map<String, Object> pageFlowMap = ctx.getPageFlowScope();
    pageFlowMap.put("number", getNumber());               //Problem line getNumber is always null
  public void setNumber(String number)
    this.number = number;
  public String getNumber()
    return number;
}I am having problem on the above line. I always get a null value on the number input text.
Why is that so as I think I have already place a value on my Bean.
For completeness sake, here's how I defined my managed bean
  <managed-bean id="__12">
    <managed-bean-name id="__9">MyBean</managed-bean-name>
    <managed-bean-class id="__11">com.testing.MyBean</managed-bean-class>
    <managed-bean-scope id="__10">request</managed-bean-scope>
  </managed-bean>Not sure but any workaround to this?
Thanks
Jdev 11G PS4

Mohammad Jabr wrote:
try to bind your input text to a property in your bean and use getValue() method.
check this nice post [url http://adfpractice-fedor.blogspot.com/2012/02/understanding-immediate-attribute.html]Understanding the Immediate Attribute
Edited by: Mohammad Jabr on Feb 22, 2012 8:25 AM
Hi, Apparently this does work. Putting a binding on the input components.
But somehow, I am reluctant to make use of any bindings as I am encountering issues when I expose this Taskflow as portlet in a Webcenter Application.
But, as I have read the article, I made changes with the code. I am not using any bindings but just making use of the valuechangelistener.
From the article, I have realized that the reason why the setter method of the bean was not called is because the Update Model Values was skipped.
Very nice article.
Thanks.

Similar Messages

  • Code returning NULL

    T1 (Table and columns & data ) used in my example
    create table T1 (col1 number,col2 number);
    col1 col2
    1 5
    2 5
    3 5
    4 5
    11 6
    12 6
    13 6
    14 6
    CREATE OR REPLACE FUNCTION TEST (par NUMBER) RETURN VARCHAR2 IS
    l_concat VARCHAR2(32767) ;
    BEGIN
    select wm_concat(col1) into l_concat from t1 where col2=par;
    RETURN l_concat;
    END;
    select TEST(5) from dual;
    The above example always returns a NULL as opposed to (1,2,3,4);
    CREATE OR REPLACE FUNCTION TEST (par NUMBER) RETURN VARCHAR2 IS
    l_concat VARCHAR2(32767) ;
    l_str varchar2(32767);
    BEGIN
    l_str:='select wm_concat(col1) from t1 where col2=:b';
    execute immediate l_str into l_concat using par;
    RETURN l_concat;
    END;
    select TEST(5) from dual;
    This returns the correct answer .i.e. (1,2,3,4);
    My question is why my first code returning NULL? Is there any restriction using aggregate functions inside
    plsql code ?

    BluShadow wrote:
    The in paramter has the same name as one of the column . Thus the select query was not taking the filtering predicate as the in parameter col1 ,rather it was
    using the column's value for filtering each row and hence the wm_concat was not getting any row to concatenate .That's why you should use a good coding standard and perhaps prefix parameters with "p" or "p_" and local variables with "v" or "v_" etc.Smacks too much of archaic Hungarian notation. :-)
    Explicit scope definition is supported by PL/SQL. So why invent a new manual standard for scope, when there exists one already?
    SQL> create or replace procedure FooProc( empNo emp.empno%Type ) is
      2          empRow  emp%RowType;
      3  begin
      4          select
      5                  e.* into empRow
      6          from    emp e
      7          where   e.empno = FooProc.empNo;
      8 
      9          dbms_output.put_line(
    10                  'Employee '||empNo||' is '||empRow.ename||
    11                  ', and employed as '||empRow.job
    12          );
    13  end;
    14  /
    Procedure created.
    SQL>
    SQL>
    SQL> exec FooProc(7369)
    Employee 7369 is SMITH, and employed as CLERK
    PL/SQL procedure successfully completed.
    SQL> Personally, I find the v_ and p_ prefix approach quite silly - attempting to address an issue that is already solved by explicit PL/SQL scope.
    Never mind that the approach of using different prefixes, attempts to identify scope - and goes down the exact same slippery scope that Hungarian notation did. Which resulted in the death of this misguided standard, many years ago.
    Frustrates me to no end to see the exact SAME mistakes made in PL/SQL that were made a decade or more ago - where lessons learned since then are conveniently ignored when it comes to PL/SQL programming.
    It is still seems to be the Dark Ages when it comes to PL/SQL development.... :-(

  • Why this broken c++ code works?

    I'm testing some flascc code, and I'm trying to trow some errors, but it seems that my tests just return NULL or zero, and never stop the execution, and I think this is not desired.
    For example:
    Error *errorClass = NULL;
    int myVar = errorClass->foo();
    I think this should trow an error while calling a function of a NULL pointer but it's not the case.
    Also, I've tried some divisions by zero, and there is no error, just returns 0

    This doesn't have to crash unless you try to access the attribute of your Error object in Error::foo().
    This is not against the c++98 standard (haven't verified), but this code will also run on vanilla gcc.
    Method code are almost like normal function, but they are given the object as a "this" parameter so it can works on its attributes.
    So let's say that in Error::foo() you do this : printf("hello world)
    What your code do is the equivalent of
         void foo(Error * this){
              std::cout << "hello world" std::endl;
         int main(){
              foo(NULL);
              return 0;
    This code won't crash, but as soon you try to access the attribute this is another story. So, it really depend on what you do in Error::foo().
    For the zero division, the standard left this as an undefined behavior. So it's perfectly normal, on some compiler/architecture it will crash, on others not. It's left to the compiler implementation as to what should happen.
    So nothing in what you say should cause the program to crash, it might, but it might not, it isn't a bug, it's just undefined in the standard.
    You should manually check for error, C++ is way more low level than AS3 it won't stop you from shooting yourself in the foot, but that's also one of the reason why it is so flexible and performant.

  • What is this line of code means???

    Hi have a general question, I am not sure if it right place to ask. But I will be grateful if some body could help on this one. I could not figure out what is that line of code (**) is doing or what does it mean. I gave sample implementation here.
    Public class Decoder{
    InputStream in
    Public Decoder(InputStream in){
    This.in = in;
    String st = somefunction(in)
    public static Xval decode(InputStream in){
    return new Decoder(in).decode(); **
    What I don�t understand that what is line of Code do �return new Decoder(in).decode(); � I have never seen this kind of implementation. The return type is Xval but the function is retrunin t object of this (Decoder) type. And what is Decoder(in).decode() when function decode() is doing nothing except returning a object???
    Thank you

    Apparently, the Decoder class has a method called decode() that returns a Xval object. The line is equivalent toDecoder d =  new Decoder(in);
    Xval xv = d.decode();
    return xv;

  • Need help in understanding this line of code...

    Hi,
    I am trying to modify an existing code and I came across this line.
            dorminLabel111.setText("<HTML> <b>18. %(demonstration_problem1_char)% was asked to solve an equation, and %(demonstration_problem1_char)% came up with the following solution, which is incorrect:</b>");I dit not understand how %(demonstration_problem1_char)% is being used. What is it supposed to do? And how can i reference that value?

    JoachimSauer wrote:
    That notation has no inherent meaning in Java, so there's probably some other code that interprets that value later on. Or perhaps before, like some kind of pre-compiler or something related to the build process that replaces those just before compiling?

  • Code returns "null" and "0"s in main module - why?

    I am coding a program that is in two modules. The main module serves it's standard function. The inventory class/module has three functions - 1) request stock input on 4 data points (1 String and 3 integers, one of which is a double) - 2) calculate the value of the inventory, and - 3) return string which reads out the 4 data points and the calculation showing the total value of the inventory. I've created the 3 functions in the inventory class/module, but obviously don't have them referring to each other correctly because when we come to the end of the program the output is null for the String and "0"s for the int/doubles. The code is below - any ideas about how to overcome the empty output? The code compiles fine and acts like it is going to work, but when it comes to the final command line it outputs
    "null, which is item number 0, has 0 currently in stock at a price of 0.00 each. The total value of inventory in stock is 0.00"
    Main module:
    public class Main {
        @SuppressWarnings("static-access")
        public static void main(String[] args) {
            Inventory inventory = new Inventory(); //call Inventory class
            inventory.inventoryInput();
            Inventory results = new Inventory();
            results.inventoryResults(); //call for inventoryResults in Inventory class
    }Inventory module:
    import java.util.Scanner;
    import static java.lang.System.out;
    public class Inventory
      //declare and initialize variables
       int itemNumber = 0;
       String productName;
       int stockAmount = 0;
       double productCost = 0;
       double totalValue = 0;
       String inventoryResults;
       //initialize scanner
       Scanner input = new Scanner(System.in);
       public void inventoryInput ()
       out.println("Please enter item number: "); //prompt for item number
          itemNumber = input.nextInt();
       out.println( "Enter product name/description: "); //prompt for product name
          productName = input.next();
       out.println("Quantity in stock: ");
          stockAmount = input.nextInt(); // prompt for stock quantity
       out.println("What is the product cost for each unit? ");
          productCost = input.nextDouble(); // prompt for product cost
        } // end inventoryInput
        public double totalValue( double stockAmount, double productCost )
          totalValue = stockAmount * productCost;
          return totalValue; // return stock value
        } // end totalValue
        public void inventoryResults()
        out.printf("%s, which is item number %d, has %d currently in stock at a " +
         "price of %.2f each. The total value of inventory in stock is " +
         "%.2f\n.", productName, itemNumber, stockAmount, productCost, totalValue);
        } // end inventoryResult
    }// end method

    justStartingOut wrote:
    Actually my final solution was quite simple - I moved the calculation and final formated print text statements into the body of Inventory's class code. It now works. "Works" scares me a bit.
    Someone cooking dinner might rummage about in the fridge and the cupboards to see what's there. Do imaginative things with what they come up with. And, with a bit of luck come up with something tasty or, at any rate edible.
    A physician deciding on a medical treatment would do well to try a more cautious approach. A specific aim would be a good thing. And a calculated appreciation of the documented effects of each medicine. And how they interact.
    It's up to you to determine which approach your coding should resemble. But it seems to me that your original Main class had a perfectly good reason to exist. It was a driver class whose purpose seemed to be to create and use an Inventory. (And using an Inventory is a very different thing from being an Inventory, so it made perfect sense to have two different classes.) To me it works or not, depending on whether it fufills that purpose. And what you have done is not so much solve the problem of it not working, as avoid that problem.
    (If by "moved" you mean that the outputting now occurs as part of - or is called from - inventoryInput() then that is not a good thing. The input method should input: just input.)
    I think that is because once the original input was loaded into the program (when I entered product number, name, price and value), the entries were dropped when the code switched to the next step. I think your intuition is entirely correct. In particular look at what your original main() method does (my comments replacing yours):
    Inventory inventory = new Inventory(); // (A) Create an inventory...
    inventory.inventoryInput(); // ... and put stuff into it
        // (B) Create some new entirely different (and empty) inventory...
    Inventory results = new Inventory();
    results.inventoryResults(); // ... and print its contentsInstead of creating a second inventory, try printing the results of the first one.
    Edited by: pbrockway2 on Apr 22, 2008 12:37 PM
    Whoops ... just read reply 2.
    It might sense, though to call totalValue() at the end your input method (because at that point the total value has changed). Or do away with that method - which you worked on getting right in your other thread ;)

  • Why this filter's code is not working right?

    Hey, I have written a filter to record every request and write to a xml file. Everything works fine but the the code in filter's destroy is called twice. Don't know why? Is that there something wrong with my file writing code?? here is the code
    Filter Code:
    package xx;
    import javax.servlet.Filter;
    import javax.servlet.FilterConfig;
    import javax.servlet.FilterChain;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    import UserInfo;
    public class RequestInspector implements Filter {
    protected RequestRecorder recorder = null;
    protected static String ipAddress;
    protected static int hrId = -1;
    public void init(FilterConfig config) {
    String fileLoc = config.getInitParameter("FileLocation");
    String fileName = config.getInitParameter("FileName");
    ipAddress = config.getInitParameter("IPAddress");
    try {
    hrId = Integer.parseInt(config.getInitParameter("HRID"));
    } catch (NumberFormatException nfe) {
    } catch (NullPointerException npe) {
    if (fileLoc != null && fileName != null && ipAddress != null && hrId != -1) {
    recorder = RequestRecorder.getInstance(fileLoc, fileName);
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest)request;
    HttpSession session = httpRequest.getSession(false);
    UserInfo info = ((session==null) ? null : (UserInfo)session.getAttribute("USER_INFO"));
    if ( request.getRemoteAddr().equals(ipAddress) && info != null && info.getHrId() == hrId && recorder != null) {
    recorder.record(httpRequest);
    } // if...
    chain.doFilter(request, response);
    public void destroy() {
    if (recorder != null) {
    recorder.stop();
    RequestRecorder Code
    package ids.util;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.Enumeration;
    import java.util.Vector;
    import java.util.Hashtable;
    import javax.servlet.http.HttpServletRequest;
    public class RequestRecorder {
    private static final Hashtable holder = new Hashtable(2);
    private FileWriter writer = null;
    private int counter = 0;
    private RequestRecorder(String fileLocation, String fileName)
    throws IOException {
    writer = new FileWriter(new File(fileLocation, fileName));
    initializeFile();
    public static RequestRecorder getInstance(String fileLocation, String fileName) {
    RequestRecorder recorder = null;
    try {
    String path = new File(fileLocation, fileName).getAbsolutePath();
    recorder = (RequestRecorder) holder.get(path);
    if (recorder == null) {
    recorder = new RequestRecorder(fileLocation, fileName);
    holder.put(path, recorder);
    } catch (IOException ioe) {
    return recorder;
    public synchronized void record(HttpServletRequest request) throws IOException {
    if (writer == null) {
    return;
    writer.write("\n\t\t<request path=\"" + request.getRequestURI() +"\" label=\"request" + (++counter) +"\">");
    Enumeration params = request.getParameterNames();
    while (params.hasMoreElements()) {
    String param = (String)params.nextElement();
    String[] paramValues = request.getParameterValues(param);
    if (paramValues != null) {
    for (int i=0; i<paramValues.length; i++) {
    writer.write("\n\t\t\t<param>");
    writer.write("\n\t\t\t\t<paramName>");
    writer.write(param);
    writer.write("</paramName>");
    writer.write("\n\t\t\t\t<paramValue>");
    writer.write(paramValues);
    writer.write("</paramValue>");
    writer.write("\n\t\t\t</param>");
    } //for...
    } //if...
    } //while...
    writer.write("\n\t\t\t<validate>");
    writer.write("\n\t\t\t\t<byteLength min=\"20\" label=\"validation" + counter+"\"/>");
    writer.write("\n\t\t\t</validate>");
    writer.write("\n\t\t</request>");
    writer.flush();
    public void stop() {
    if (writer != null) {
    try {
    finalizeFile();
    writer.close();
    writer = null;
    } catch (IOException ioe) {
    ioe.printStackTrace();
    private synchronized void initializeFile() throws IOException {
    writer.write("<?xml version=\"1.0\" standalone=\"no\"?>");
    writer.write("\n<!DOCTYPE suite SYSTEM \"../conf/suite.dtd\">");
    writer.write("\n<suite defaultHost=\"tiserver.com\" defaultPort=\"8899\" label=\"test\">");
    writer.flush();
    private synchronized void finalizeFile() throws IOException {
    writer.write("\n\t</session>");
    writer.write("\n</suite>");
    writer.flush();
    protected void finalize() {
    stop();
    }The XML output file looks like this
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE suite SYSTEM "../conf/suite.dtd">
    <suite defaultHost="tiserver.com" defaultPort="8899" label="test">
    <request path="/acfrs/loginP.jsp" label="Login">
    <param>
    <paramName>userId</paramName>
    <paramValue>redfsdf</paramValue>
    </param>
    <param>
    <paramName>passWord</paramName>
    <paramValue>h1dffd3dfdf</paramValue>
    </param>
    <validate>
    <regexp pattern="Invalid Login" cond="false" ignoreCase="true" label="Login Check"/>
    </validate>
    </request>
    </session>
    </suite>frs/left_frame.jsp" label="request1">
    <validate>
    <byteLength min="20" label="validation1"/>
    </validate>
    </request>
    <request path="/acfrs/welcome.jsp" label="request2">
    <validate>
    <byteLength min="20" label="validation2"/>
    </validate>
    </session>
    </suite>
    If you closely observe the XML file "</session> </suite>" is written in the middle of the file too. Why does this happen? By the way, this code works perfectly on my windows desktop but on unix server the above problem turns up. Any clues??
    Thanks

    Ooops! The finalize() method in RequestRecorder is redundant. Mistakenly uncommnented it (finalize() method code ) while posting it here :-)

  • Why this binding keeps the text indent always one tick behind it shoud be???

    public partial class MainWindow : Window, INotifyPropertyChanged
    public MainWindow()
    InitializeComponent();
    this.DataContext=this;
    // Declare the event
    public event PropertyChangedEventHandler PropertyChanged;
    private double indent;
    public double Indent
    get { return indent; }
    set
    indent = value;
    // Call OnPropertyChanged whenever the property is updated
    OnPropertyChanged("Indent");
    private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
    Slider slider = sender as Slider;
    var track = (Track)slider.Template.FindName("PART_Track", slider);
    if (track != null)
    var repeatButton1 = (RepeatButton)track.DecreaseRepeatButton;
    Indent = repeatButton1.ActualWidth;
    // Create the OnPropertyChanged method to raise the event
    protected void OnPropertyChanged(string name)
    PropertyChangedEventHandler handler = PropertyChanged;
    if (handler != null)
    handler(this, new PropertyChangedEventArgs(name));
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition />
    <RowDefinition Height="30" />
    </Grid.RowDefinitions>
    <RichTextBox x:Name="rtb1" BorderBrush="Gray" Padding="0"
    ScrollViewer.VerticalScrollBarVisibility="Auto"
    IsDocumentEnabled="True" UseLayoutRounding="False"
    BorderThickness="0" SnapsToDevicePixels="True" IsSnaptoTickEnabled = "True" Grid.IsSharedSizeScope="True" ClipToBounds="True" IsManipulationEnabled="True">
    <FlowDocument>
    <Paragraph TextIndent="{Binding Indent}">
    Test Paragraph
    </Paragraph>
    </FlowDocument>
    </RichTextBox>
    <Slider Grid.Row="1" Maximum="10" Minimum="0" Style="{StaticResource MySlider}" ValueChanged="Slider_ValueChanged" />
    </Grid>
    It just happens when IsSnaptoTick is enable or when clicking increase or decrease buttons. Why?

    Hi Denis,
    IsSnapToTickEnabled is a property to "Gets or sets a value that indicates whether the
    Slider automatically moves the Thumb to the closest tick mark. "
    I will recommend you check the value of your thumb to know whether it is close to the one you needed. I suppose your problem is actually due to that value is more close to another tick.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • What does this line of code do: ?xml version="1.0" encoding="windows-1252"?

    When I add this code to a new xhtml file and validate for XML I get the following error: Character Encoding mismatch! [XHTML 1.0 Transitional]

    Google says: http://www.w3schools.com/xml/xml_encoding.asp
    If this is of no help, you'll need to give a little more info - like what did you do, the code, why your using a windows encoding etc.

  • Can someone explain to me how this line of code works?

    My friend put in this code to my game script
    if CollisionDistance < 2 then
    else if "pMushroom" = string(collisionModel).char[8..16] then
    pInfo = member("Info") 
          pInfo.Text = "Press 'F' to consume Mushroom"
    else
    end if
    else
        pInfo = member("Info") 
        pInfo.Text = ""
      end if
    So this is used in my game so that when a ray is less than 2 units away to hits an object named pMushroom, instructions would come up that say "Press 'F' to consume Mushroom" (I'm sure you already knew that though).
    I have a bunch of mushrooms out lebed pMushroom01 - pMushroom09
    I tried to use this for other models like:
    else if "pStick" = string(collisionModel).char[8..16] then
    pInfo = member("Info") 
           pInfo.Text = "Press 'F' to take Stick"
    But the instructions do not pop up. I've checked that I was the right distance away with my collision detection.
    Could someone explain to me the code and what could possibly be wrong?
    "char[8..16]" is what I really don't get.

    collisionModel is most likely a property variable. So "else if "pStick" = string(collisionModel).char[8..16] then" is taking whatever is in that variable, and setting it as a string. Then it is parsing out the characters in that string from character 8 to character 16 and comparing that sub string to the string pStick.
    This works in the first example because "pMushroom" has 9 characters. "pStick" has six characters and so it will never be equal to those characters in collisionModel. You might try:
    else if "pStick" = string(collisionModel).char[8..13] then
    it may work.

  • What is the meaning of this line of code

    hi
    we have time.xls file
    on file the first
    Time A , B , C
    07:00 07:47 08:48 09:35
    and in java we have
    if (courseType == COURSE_OLD)
                return generateTimes(startingTime, 53, 2 * 60, 2 * 60 + 53, 0);what is coding 's meaning??
    Thank you

    the whole java class in here
    import java.util.Calendar;
    import java.util.Date;
    public class StartingTimeUtils {
        public static int COURSE_OLD = 0;
        public static int COURSE_NEW = 1;
        public static int COURSE_EDEN = 2;
        public static String[] getSummerSixMinute23BallRule(int courseType, Date startingTime, boolean title) {
            if (title) // return titles only
                return commonCourse1(courseType);
            } else {
                if (courseType == COURSE_OLD)
                    return generateTimes(startingTime, 47, 60 + 48, 2 * 60 + 35, 0);
                if (courseType == COURSE_NEW)
                    return generateTimes(startingTime, 60 + 59, 2 * 60 + 47, 0, 0);
                if (courseType == COURSE_EDEN)
                    return generateTimes(startingTime, 24, 60 + 19, 2 * 60 + 30, 3 * 60 + 6);
            return new String[]{"", "", "", ""};
        public static String[] getSummerSevenMinute34BallRule(int courseType, Date startingTime, boolean title) {
            if (title) // return titles only
                return commonCourse1(courseType);
            else
                return commonTime1(courseType, startingTime);
        public static String[] getSummerEightMinuteAnyGame34BallRule(int courseType, Date startingTime, boolean title) {
            if (title) // return titles only
                return commonCourse1(courseType);
            else
                return commonTime1(courseType, startingTime);
        public static String[] getWinterSixMinute23BallRule(int courseType, Date startingTime, boolean title) {
            if (title) // return titles only
                return commonCourse1(courseType);
            else
                return commonTime2(courseType, startingTime);
        public static String[] getWinterSevenMinuteAnyGameRule(int courseType, Date startingTime, boolean title) {
            if (title) // return titles only
                return commonCourse1(courseType);
            else
                return commonTime3(courseType, startingTime);
        public static String[] getWinterEightMinuteAnyGameRule(int courseType, Date startingTime, boolean title) {
            if (title) // return titles only
                return commonCourse1(courseType);
            else
                return commonTime3(courseType, startingTime);
        /* Add each time and return as time string eg 12:55 */
        private static String[] generateTimes(Date startingTime, int i, int j, int k, int l) {
            Calendar cal1 = Calendar.getInstance();
            cal1.setTime(startingTime);
            cal1.add(Calendar.MINUTE, i);
            String time1 = "";
            if (i > 0)
                time1 = StringFormater.formatTime(cal1.getTime());
            Calendar cal2 = Calendar.getInstance();
            cal2.setTime(startingTime);
            cal2.add(Calendar.MINUTE, j);
            String time2 = "";
            if (j > 0)
                time2 = StringFormater.formatTime(cal2.getTime());
            Calendar cal3 = Calendar.getInstance();
            cal3.setTime(startingTime);
            cal3.add(Calendar.MINUTE, k);
            String time3 = "";
            if (k > 0)
                time3 = StringFormater.formatTime(cal3.getTime());
            Calendar cal4 = Calendar.getInstance();
            cal4.setTime(startingTime);
            cal4.add(Calendar.MINUTE, l);
            String time4 = "";
            if (l > 0)
                time4 = StringFormater.formatTime(cal4.getTime());
            return new String[]{time1, time2, time3, time4};
        private static String[] commonTime1(int courseType, Date startingTime) {
            if (courseType == COURSE_OLD)
                return generateTimes(startingTime, 53, 2 * 60, 2 * 60 + 53, 0);
            if (courseType == COURSE_NEW)
                return generateTimes(startingTime, 2 * 60 + 27, 3 * 60 + 6, 0, 0);
            if (courseType == COURSE_EDEN)
                return generateTimes(startingTime, 27, 60 + 30, 2 * 60 + 50, 3 * 60 + 30);
            return new String[]{"", "", "", ""};
        private static String[] commonTime2(int courseType, Date startingTime) {
            if (courseType == COURSE_OLD)
                return generateTimes(startingTime, 46, 60 + 42, 2 * 60 + 28, 0);
            if (courseType == COURSE_NEW)
                return generateTimes(startingTime, 2 * 60 + 5, 2 * 60 + 39, 0, 0);
            if (courseType == COURSE_EDEN)
                return generateTimes(startingTime, 23, 60 + 15, 2 * 60 + 23, 2 * 60 + 58);
            return new String[]{"", "", "", ""};
        private static String[] commonTime3(int courseType, Date startingTime) {
            if (courseType == COURSE_OLD)
                return generateTimes(startingTime, 51, 60 + 55, 2 * 60 + 46, 0);
            if (courseType == COURSE_NEW)
                return generateTimes(startingTime, 2 * 60 + 22, 3 * 60 + 10, 0, 0);
            if (courseType == COURSE_EDEN)
                return generateTimes(startingTime, 26, 60 + 27, 2 * 60 + 43, 3 * 60 + 22);
            return new String[]{"", "", "", ""};
        public static String[] commonCourse1(int courseType) {
            if (courseType == COURSE_OLD)
                return new String[]{"5 Tee", "� House", "14 Tee", ""};
            if (courseType == COURSE_NEW)
                return new String[]{"� House", "15 Tee", "", ""};
            if (courseType == COURSE_EDEN)
                return new String[]{"3 Tee", "7 Tee", "� House", "16 Tee"};
            return new String[]{"", "", "", ""};
    }

  • A getName method allways returns null, why?

    I have an
    ArrayList<Animals> array_list = new ArrayList<Animals>();
    LinkedList<Animals> linked_list = new LinkedList<Animals>();
    I want the getName() method in class NewListener to be accessed from the class NextListener which extends NewListener, and therefor should get access to the method. But when I run the program, it allways returns null. Why?
    class NewListener implements ActionListener
              public String name;
              public void actionPerformed(ActionEvent e)
                   String str_name = showInputDialog(this,"Animal name: ",null);
                   if(str_name == null)
                        return;
                   for(int i=0; i<array_list.size(); i++)
                        if(array_list.get(i).getName().equalsIgnoreCase(str_name))
                             setName(str_name);                   // set the name with the setName() method
                             linked_list.add(array_list.get(i));
              public void setName(String name)
                   this.name=name;
              public String getName()
                   return name;        // this line returns "null"
                         // return "Hello";    // this line works and returns "Hello"
         class NextListener extends NewListener implements ActionListener
              public void actionPerformed(ActionEvent e)
                   try
                        linked_list .removeFirst();
                   }catch(NoSuchElementException er)
                        System.out.println("Numerical value");
                   String info =  getName()+" is in line";   // Why does the getName() method in the NewListener allways return a null?
                   showMessageDialog(this, info, "Notice", INFORMATION_MESSAGE);
         }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Roxxor wrote:
    Ok, I changed the name to private and I also tried with
    public void setName(String name)
    System.out.println("setting name on " + this + " to " + name); // <--- ADD THIS LINE
    this.name=name;
    }and it works. So this.name SHOULD get the value of name, but it doesn�t.
    So the question is: why does getName() return null?Your code is doing exactly what you're telling it to do. One or more of your assumptions is wrong. Keep digging. Add more print statements.
    Above all, you must drop the attitude that "it should work." There's a bug in your code. You have to find it. Repeating the mantra "It should work" is simply going to put blinders on and make it almost impossible to find your error. Instead, you have to think, "What did I do wrong?" and "If getName is returning null, then setName was never called or was called with null."

  • I am trying to raise event at UserControl, and catch it at Main program, But the event always return null

    I am trying to raise a event in one of classes of userControl, and Fire it in the Main class. I tried two different ways to fire this event, one of them works, But I still want to know why other way cannot work, and how to fix it.
    My userContol class:
    public partial class UserControl1 : UserControl
    public UserControl1()
    InitializeComponent();
    if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
    return;
    Class1 c = new Class1();
    Thread accept = new Thread(
    () =>
    c.connection();
    accept.Start();
    And the Class1:
    public class Class1
    public delegate void myhandler(object sender, EventArgs e);
    public event myhandler test;
    public Class1()
    public void connection()
    test(this, new EventArgs());
    In the Main, I just simply add into referent, and add
    xmlns:my="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
    then I try to subscribe this event in the main
    public partial class SurfaceWindow1 : SurfaceWindow
    /// <summary>
    /// Default constructor.
    /// </summary>
    public SurfaceWindow1()
    InitializeComponent();
    Class1 c = new Class1();
    c.test+=new Class1.myhandler(c_test);
    // Add handlers for window availability events
    AddWindowAvailabilityHandlers();
    public void c_test(object sender, EventArgs e)
    MessageBox.Show("fire");
    If I only raise this event not into thread, it works fine, but If I try to let it raise in this thread, this test event only return null, and shows:
    Object reference not set to an instance of an object.
    looks like I did not subscribe it ever. So How to fix it if I must use it in thread.

    Subscribing to events window to class is not a great approach.
    You have to then go un subscribe those handlers in order to allow your instance to be disposed.
    Forget that and you'll eventually notice you have memory leaks.
    The way I do this sort of thing is using mvvm light messenger.
    You can keep everything decoupled then.
    http://social.technet.microsoft.com/wiki/contents/articles/26070.aspx
    I just did a bit of code for someone else which shows how to do cross thread stuff with this approach.
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    Messenger.Default.Register<String>(this, (action) => ReceiveString(action));
    private void ReceiveString(string msg)
    MessageBox.Show(msg);
    Dispatcher.BeginInvoke((Action)delegate()
    tb.Text = msg;
    private void Button_Click(object sender, RoutedEventArgs e)
    Task.Factory.StartNew(() => {
    Messenger.Default.Send<String>("Hello World");
    Note that the message arrives on the thread it was sent from. That's not the ui thread because it was sent from that task.factory.startnew to deliberately put it on a different thread.
    In order to change UI controls, it uses dispatcher.begininvoke to run code on the UI thread.
    Although this is in one piece of code behind publisher and subscriber can be in two totally different classes which have no reference of knowledge of each other.
    Meaning you can send a message<t> from any class1 or whatever you like and your mainwindow can subscribe and act of receipt of a message<t>.
    It is the type which defines which message one is. You put data you want to send in t and use it in the subscriber.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • What is the error in this one line of code!

    s=s-(s/28)*[1-(s/28)*(29/s+1)*(21-q/11)];
    I am using this line of code in my programe but i am getting the following error.
    C:\shahzad\Easter.java:28: illegal start of expression
    s=s-(s/28)*[1-(s/28)*(29/s+1)*(21-q/11)];
    Please help me solvingg this problem
    thanks.

    s=s-(s/28)*[1-(s/28)*(29/s+1)*(21-q/11)];
    [] brakets ae used to index arrays, are you using an array somewhere????
    arr=5; for example....
    in either event youl need to make changes.
    assuming no array is involved simply change [] to ()
    if still causing problems try adding extara()
    s= (s-(s/28))*( (1-(s/28)) * ( (29/s)+1) * (21-(q/11)) );

  • Get textFrame by label returns null and anchored objects

    I have the following two functions:
    function getByLabel(page, label)
        for(var i=0; i < page.allPageItems.length; i++)
            if( page.allPageItems[i].label == label )
                return page.allPageItems[i];
    and
    Object.prototype.findItems = function(/*obj*/props)
        if( !('everyItem' in this) )
            throw new Error("Error: " + this + " is not a collection.");
        var ret = this.everyItem().getElements(),
            i = ret.length,
            e, p;
        while( i-- && e=ret[i] )
            for( p in props )
                if( (p in e) && e[p]===props[p] ) continue;
                ret.splice(i,1);
        return ret;
    In my page structure, I got one main text frame (the content area) and two vertical text fromes on the sides of the page. There is also a small box textframe on top of the page. All these textboxes EXCEPT the main text frame are ALL "ANCHORED objects". I had to make them anchored objects, eitherwise after importing data, the boxes would jump around. (Example, the small box textframe that is on the top would get moved to the content area textframe etc). Not sure if using anchored objects is the proper way to fix this.
    When I try to get the small box text frame, it does not work using the findItems (returns null) but it works fine with the getByLabel method. Why is that?
    The calling syntax is:
    for( i=0 ; i < doc.pages.length ; ++i )
            var page = doc.pages.item(i);
            var textFrame = getByLabel(page, 'lblSection' ); //This works
            //   var textFrame = page.textFrames.findItems({ label:  'lblSection' })[0]; This does not work, returns null
            if( textFrame != null )
                textFrame.parentStory.contents = "";

    (function () {
        // Per the InDesign Scripting Guide, app.activeScript is only
        // valid when a script is directly executed from InDesign, not
        // from the ESTK, so a try/catch block is recommended to handle
        // it.
        var d;
        try {
            d = app.activeScript.parent.parent.fsName;
        } catch (e) {
            d = Folder.appPackage.parent.fsName+"/Scripts";
            return d;

Maybe you are looking for

  • Photo stream is not working on 4s.

    Photo stream hasn't worked for over a week now. It seems to only work when I take a pic while connected to wifi but if I'm out somewhere, take pics, come home and connect to wifi it still won't stream my photos.

  • Scrolling long folder names in Mailboxes pane

    Is there a way to horizontally scroll long folder names? I have several folders with long names and deep sub-folder hierarchies. Stretching the Mailboxes pane and then selecting the folder and hiding the pane to get back screen real estate works but

  • Is there any class to get the head, title, anchors of any page?

    hi, i am study at computer science and i have a senior project that is related to Focused Crawler. 1 ) So, i have an issue. I have to get head,title,metas, anchors of any page. But, i don't want to recode it, may be there any classes that performs my

  • Yoga 3 - system locks up - why?

    I have a newly acquired refurbished yoga 3 - very nice appearance. Performance sometimes problematic as system freezes for 15-30 seconds... any ideas what might cause this - what should I troubleshoot? Solved! Go to Solution.

  • Problemas al abrir archivos en Premiere CC PRO

    como hago para abrir archivos de una versión mas actualizada de Premiere cc pro en una versión desactualizada?Pro