Results 1 to 3 of 3

Thread: how to pass one bean value to another bean

  1. #1

    Default how to pass one bean value to another bean

    I am trying to process the name in two different beans as follows. Basically the original "get/setName" for name is working fine. I am tyring to process this name in another bean by name "set/getNamesAsString" so that I can use it in another part of jsp. Is it possible to do it like this. It is not working. Can anyone help me in this.
    Code:
    public class MyForm {
    
       private String name;
     
       public void setName(String name){
          this.samples = samples;
       }
    
       public String getname(){
          return name;
       }
        private List<String> namesAsString;   
      
      private String names = this.name;
    
      public List<String> getNamesAsString(){
          
           return namesAsString;
           
       }
               
       public void setNamesAsString(String names){
          
            String[] multiSamples = name.split("\r\n|\r|\n");
            List<String> multiNames = new ArrayList();
    
            for(int i=0; i <= multiSamples.length-1; i++){
                if(multiSamples[i] != null && multiSamples[i].length() != 0){
                    
                  multiNames.add(multiSamples[i]);                          
                }          
            }
           
           this.namesAsString = multiNames;
           
       }
    
    }
    Thanks

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Please don't post duplicates.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by mdeinum View Post
    Please don't post duplicates.
    I am sorry about that. As a newbee, I am not sure where my query stands, hence I had topost it twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •