• affable
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies

hi mates, please help me in this sceanario: i have created three custom object book1__c, publisher__c, author__c

In book1__c i gave lookup to two customer objects (author__c, publisher__c) . in visual page am able to get the input feilds of author__c , publisher__ci.e author name, publisher name) . that are lookup feilds  when i use to select the author name from lookup feild and publisher name from lookup and click the search button i should able to display the current book details of assosiated author name and publisher name but am not able to display the desired result. Instead it displays the default book record. please Help me

 

Advance thanks, 

Apex Code: custom Controller:

----------------------------------------

public class BookController

{

String Aname='chaitanya';

String Pname='dinesh';
ID id,id1;

List<book1__c> booklist;
public String getAuthorName()
{
return Aname;
}
//selected List value.
public String getPublisherName()
{
return Pname;
}
public void setAuthorName(String Aname)
{
this.Aname=Aname;
}
public void setPublisherName(String Pname)
{
this.Pname=Pname;
}
public PageReference search()
{
pageReference l = new pageReference ('/apex/bookList');
return l;
}
public PageReference showList()
{
pageReference n= new pageReference('/apex/showList');
return n;
}

public List<book1__C> getBooklist()
{
id=[select name from author__c where name=:Aname].Id;
id1=[select name from publisher__c where name=:Pname].ID;
booklist=[select name,price__c,bookId__c from book1__c where authorId__c=:id and publisherId__c=:id1];
return booklist;
}
}

 

visual page for input :

<apex:page controller="BookController">

<apex:form>

<apex:PageBlock mode="edit">
<apex:pageMessages />
<apex:pageBlocksection >
<apex:pageBlockSectionItem >

<apex:inputField value="{!book.authorId__c}"/>
<apex:inputField value="{!book.publisherId__c}"/>

</apex:pageBlockSectionItem>
<apex:commandButton value="search" action="{!search}"/>
<apex:commandButton value="show" action="{!showList}"/>
</apex:pageBlockSection>
</apex:PageBlock>

</apex:form>

</apex:page>

this visual page is used for displaying output.

 visual Page

-----------------

<apex:page controller="BookController">
<apex:form >
<apex:pageBlock >
<apex:pageBLockSection >
<apex:pageBLockSectionItem >
<apex:dataTable value="{!Booklist}" var="b">

<apex:column value="{!b.name}"/>

<apex:column value="{!b.price__c}"/>

<apex:column value="{!b.bookId__c}"/>
</apex:dataTable>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:PageBlock>
</apex:form>
</apex:page>


hi mates  please help in below Scenario;

Scenario: i have visual page consists of three feilds name,price,address and save button. when i click on save button these fileds information must be stored  as record in custom tableor object Book1__c .

please provide code for this Scenario.

 

 

I have tried with some smple code but its not working am new to apex Language;

 

public class Book3
{
string name=null;
Double Bookprice=null;
Integer Bookid=null;
public Book1__c newbook;
public Book3()
{
 ID id=ApexPages.CurrentPage().getParameters().get('id');
 newbook = (id == null)?new Book1__c():
 [select Bookid__c,name,Bookprice__c from Book1__c where id=:id];
}

public String getName()
 {
 return name;
 }
 public void setName(String name)
 {
  this.name=name;
 }
public Integer getNumber()
 {
 return Bookid;
 }
public void setNumber(Integer Bookid)
{
 this.Bookid=Bookid;
}  
  public Double getprice()
 {
 return Bookprice;
 }
public void setprice(Double  Bookprice)
{
 this.Bookprice=Bookprice;


public Book1__c getbook()
{
 return newbook;
 }
public pageReference save()
{
 try{
  upsert newbook;
  }
  catch(System.DmlException e)
  {
  ApexPages.addMessages(e);
  return null;
  }
  return null;
  }
  }

 

 


visual page
-----------
<apex:page controller="Book3">
<apex:form >
<apex:pageBlock title="This is sample" mode="edit">
<apex:pageMessages />
NAME: &nbsp;&nbsp;&nbsp;&nbsp;
<apex:inputText value="{!Name}"/>
<br/>
BOOKID:&nbsp;&nbsp;&nbsp;&nbsp;
<apex:inputText value="{!Number}"/>
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

i have two custom obects dep2__c and emp2__c , i have related dep2__c object to emp2__c through lookup.

 i have to select start date and endate  and department number then  ihave fetch according to selected values. but am unable to bind date in visual page .and fetch corresponding records.

help me to write apex code for above issue .

 

public class Dcontroller
{
Date sate;
Date startdate;
Date enddate;

List<dept2__c> deptList;// departmentList
List<emp2__c> employeesList;//employeeList
String departmentNumber='10';
public Dcontroller()
{
 employeesList=[select name,Id,doj__c from emp2__c];
 deptList =[select Id,name,dept2No__c,Location__c from dept2__c];
 startdate=[select doj__c from emp2__c].doj__c;
 enddate=[select doj__c from emp2__c].doj__c;
 }
 public List<emp2__c> getdate()
 {
  List<emp2__c> sate;
  sate=[select doj__c,name,Address__c from emp2__c];
  return sate;
  }
public List<SelectOption> getItems()
{
List<selectOption> options = new List<selectOption>();
 for(dept2__c dept : deptList)
 {
  String departmentNumber1 =String.valueOf(dept.dept2No__c);
  options.add(new selectOption(departmentNumber1,dept.name));
 }
 return options;
}
 public Date getSDate()
 {
  return startdate;
 }
 public void setSDate(Date sdate)
 {
  startdate =[select doj__c from emp2__c where doj__c=:sdate].doj__c;
  }
   public Date getEDate()
 {
  return enddate;
 }
 public void setEDate(Date edate)
 {
  this.enddate=[select doj__c from emp2__c where doj__c =:edate].doj__c;
  }
  public String getdepartmentNumber()
 {
 return departmentNumber;
 }
 public void setdepartmentNumber(String departmentNumber)
 {
 this.departmentNumber=departmentNumber;
 }
  public List<emp2__c> getemployees()
 {
 
  Id id=[select Id from dept2__c where dept2No__c=:departmentNumber].ID;
  employeesList=[select name,doj__c,employeeId__c,salary__c,Address__c from emp2__c where dept2No__c=:id and (doj__c=:startdate or doj__c=:enddate)];
  return employeesList;
 }
 public pageReference go()
 {
 return null;
 }
 }

 

 

i have created emp2__c object for employees and dep2__c object  for department. ,  emp2__c is related to dep2__c (lookup). if i select deptName and press btton go i should view the records of corresponding employees associated with department name . but  instead am getting ids. help me in this issue.

 

controller:

public class departmentConrtroller
{
List<dept2__c> deptList;// departmentList
List<emp2__c> employeesList;//employeeList

String departmentNumber='10';
public departmentConrtroller()
{
 deptList =[select Id,name,dept2No__c,Location__c from dept2__c];
 }
//select options
public List<SelectOption> getdepartmentItems()
{

List<selectOption> options = new List<selectOption>();
 
for(dept2__c dept : deptList)
 {
  String departmentNumber1 =String.valueOf(dept.dept2No__c);
  options.add(new selectOption(departmentNumber1,dept.name));
 }
 return options;
}
 
 public String getdepartmentNumber()
 {
 return departmentNumber;
 }
 public void setdepartmentNumber(String departmentNumber)
 {
 this.departmentNumber=departmentNumber;
 }
 public List<emp2__c> getemployees()
 {
  Id id=[select Id from dept2__c where dept2No__c=:departmentNumber].ID;
  employeesList=[select name,employeeId__c,  salary__c,Address__c from emp2__c where dept2No__c=:id];
  return employeesList;
 }
 public PageReference go()
 {
 return null;
 }
 }

 

visualpage: sx

 

 

<apex:page controller="departmentConrtroller">
<apex:form >
<apex:selectList value="{!departmentNumber}">
<apex:selectOptions value="{!departmentItems}"/>
</apex:selectList>
<apex:commandButton value="go" action="{!go}"/ >

</apex:form>
<apex:outputText value="{!employees}"/>
</apex:page>

hi am unable to resolve these issues  please  help me :

 

I have created two custome objects emp and dept1 , and i took master realation ship in employee table and related to dept1 table . when am able to write customer controller and visual page am getting following errors.

 

Error: Compile Error: unexpected token: '(' at line 13 column 70

public class SController
{
Integer departmentNumber;
List<emp__c> employees;
public Scontroller ()
{
employees=[select departmentNumber__c,id__c,sal__c,Name from emp__c where departmentNumber__c=:departmentNumber];
}
public Integer getDepartmentNumber()
 {
 return departmentNumber;
 }
public void setDepartmentNumber(ApexPages.currentPage.getParameter.get('departmentNumber'))
   {
   this.departmentNumber=ApexPages.currentPage.getParameter.get('departmentNumber');
   public List<emp__c>  getEmployees()
   {
   return employees;
   }
 public PageReference go()
  {
  return null;
  }
  }

 

 

 

ERROR: there is no SController Apex class Create: public class SController or create apex class public "sharing with" SController.

 

<apex:Page controller="SController">
<apex:form>
<apex:pageBlock title="employeeslist of current department">
<apex:pageBlockSection>
<apex:inputField value="{!dept1__c.number__c}" id="departmentNumber"/>
<apex:commandButton value="go" action="{!go}"

reRender="departmentNumber"/>
</apex:pageBlockSection>
<apex:pageBlockSection>
<apex:pageBlockTable title="current employees" value="{!employees}"

var="e">
<apex:column value="{!e.sal__c}"/>
<apex:column  value="{!e.id__c}"/>
<apex:column  value="{!e.Name}"/>
<apex:column  value="{!e.departmentNumber__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 when able to install for force. com ide through eclipse it displays error message.

help me..

 

n error occurred while collecting items to be installed
session context was:(profile=SDKProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Problems downloading artifact: osgi.bundle,com.salesforce.ide.api,24.0.0.201202291629.
MD5 hash is not as expected. Expected: 7251ab037ae632a5a9835c7c07210451 and found f5322e82ea38f9bb422e8ca66c8cfd8c.
Problems downloading artifact: osgi.bundle,com.salesforce.ide.core,24.0.0.201202291629.
MD5 hash is not as expected. Expected: 44db36699ca7fdd38917fced4e63c3b3 and found 0c60b35f796e17a5be500c8a2bd4b706.
Problems downloading artifact: osgi.bundle,com.salesforce.ide.documentation,24.0.0.201202291629.
MD5 hash is not as expected. Expected: 6d87eb2e76e7e19f7b709682e5272dfc and found a5cdc09598587cab18abca1fe1b4e553.

 

public class College
{
 // college name.
 Public Static final String CollegeName ='Tirumala Engg College';
 // college address.
 public Static final String  CollegeAdress='kesaraGutta,Bogaram,Hyderabad.';
 //college Year of Establishment.
 public Static final Integer DOE=1990;
 // creating Student class
 public class StudentClass
  {
  // creating properties for the required Student feilds(student number,student name,student address etc).
   public Integer sNo{get;set;}
   public String sName{get;set;}
   public String sAddress{get;set;}
   public Integer doj{get;set;}
   public String course{get;set;}
  }
  public class InstructorClass
  {
  // creating properties for Instructor feilds.
   public Integer iNo{get;set;}
   public String iName{get;set;}
   public String iQualification{get;set;}
   public Integer iDeptno{get;set;}
   }
   public class DeptClass
  {
  //creating properties for Department feilds.
   public Integer deptNo{get;set;}
   public String deptName{get;set;}
   public String deptLoc{get;set;}
   }
   //creating a list of students
   public List<StudentClass> students =new List<StudentClass>();
   ////creating a list of Instructors
   public List<InstructorClass> instructors =new List<InstructorClass>();
   //creating a list of Departments
   public List<DeptClass> departments =new List<DeptClass>();
   
  /* public String College()
   {
    return 'Welcome to '+ College.CollegeName;
    }*/
    
    public static StudentClass searchStudent(Integer stNo,List<StudentClass> Stds)
    {
       for(College.StudentClass student:stds)
         {
          if(Stds.sNo==stNo)
           {
           return student;
           }
           }
           }
    }
    
    hi can tell what's the error , am unable to understand error. any suggestion
   

hi mates, please help me in this sceanario: i have created three custom object book1__c, publisher__c, author__c

In book1__c i gave lookup to two customer objects (author__c, publisher__c) . in visual page am able to get the input feilds of author__c , publisher__ci.e author name, publisher name) . that are lookup feilds  when i use to select the author name from lookup feild and publisher name from lookup and click the search button i should able to display the current book details of assosiated author name and publisher name but am not able to display the desired result. Instead it displays the default book record. please Help me

 

Advance thanks, 

Apex Code: custom Controller:

----------------------------------------

public class BookController

{

String Aname='chaitanya';

String Pname='dinesh';
ID id,id1;

List<book1__c> booklist;
public String getAuthorName()
{
return Aname;
}
//selected List value.
public String getPublisherName()
{
return Pname;
}
public void setAuthorName(String Aname)
{
this.Aname=Aname;
}
public void setPublisherName(String Pname)
{
this.Pname=Pname;
}
public PageReference search()
{
pageReference l = new pageReference ('/apex/bookList');
return l;
}
public PageReference showList()
{
pageReference n= new pageReference('/apex/showList');
return n;
}

public List<book1__C> getBooklist()
{
id=[select name from author__c where name=:Aname].Id;
id1=[select name from publisher__c where name=:Pname].ID;
booklist=[select name,price__c,bookId__c from book1__c where authorId__c=:id and publisherId__c=:id1];
return booklist;
}
}

 

visual page for input :

<apex:page controller="BookController">

<apex:form>

<apex:PageBlock mode="edit">
<apex:pageMessages />
<apex:pageBlocksection >
<apex:pageBlockSectionItem >

<apex:inputField value="{!book.authorId__c}"/>
<apex:inputField value="{!book.publisherId__c}"/>

</apex:pageBlockSectionItem>
<apex:commandButton value="search" action="{!search}"/>
<apex:commandButton value="show" action="{!showList}"/>
</apex:pageBlockSection>
</apex:PageBlock>

</apex:form>

</apex:page>

this visual page is used for displaying output.

 visual Page

-----------------

<apex:page controller="BookController">
<apex:form >
<apex:pageBlock >
<apex:pageBLockSection >
<apex:pageBLockSectionItem >
<apex:dataTable value="{!Booklist}" var="b">

<apex:column value="{!b.name}"/>

<apex:column value="{!b.price__c}"/>

<apex:column value="{!b.bookId__c}"/>
</apex:dataTable>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:PageBlock>
</apex:form>
</apex:page>


hi mates  please help in below Scenario;

Scenario: i have visual page consists of three feilds name,price,address and save button. when i click on save button these fileds information must be stored  as record in custom tableor object Book1__c .

please provide code for this Scenario.

 

 

I have tried with some smple code but its not working am new to apex Language;

 

public class Book3
{
string name=null;
Double Bookprice=null;
Integer Bookid=null;
public Book1__c newbook;
public Book3()
{
 ID id=ApexPages.CurrentPage().getParameters().get('id');
 newbook = (id == null)?new Book1__c():
 [select Bookid__c,name,Bookprice__c from Book1__c where id=:id];
}

public String getName()
 {
 return name;
 }
 public void setName(String name)
 {
  this.name=name;
 }
public Integer getNumber()
 {
 return Bookid;
 }
public void setNumber(Integer Bookid)
{
 this.Bookid=Bookid;
}  
  public Double getprice()
 {
 return Bookprice;
 }
public void setprice(Double  Bookprice)
{
 this.Bookprice=Bookprice;


public Book1__c getbook()
{
 return newbook;
 }
public pageReference save()
{
 try{
  upsert newbook;
  }
  catch(System.DmlException e)
  {
  ApexPages.addMessages(e);
  return null;
  }
  return null;
  }
  }

 

 


visual page
-----------
<apex:page controller="Book3">
<apex:form >
<apex:pageBlock title="This is sample" mode="edit">
<apex:pageMessages />
NAME: &nbsp;&nbsp;&nbsp;&nbsp;
<apex:inputText value="{!Name}"/>
<br/>
BOOKID:&nbsp;&nbsp;&nbsp;&nbsp;
<apex:inputText value="{!Number}"/>
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

i have created emp2__c object for employees and dep2__c object  for department. ,  emp2__c is related to dep2__c (lookup). if i select deptName and press btton go i should view the records of corresponding employees associated with department name . but  instead am getting ids. help me in this issue.

 

controller:

public class departmentConrtroller
{
List<dept2__c> deptList;// departmentList
List<emp2__c> employeesList;//employeeList

String departmentNumber='10';
public departmentConrtroller()
{
 deptList =[select Id,name,dept2No__c,Location__c from dept2__c];
 }
//select options
public List<SelectOption> getdepartmentItems()
{

List<selectOption> options = new List<selectOption>();
 
for(dept2__c dept : deptList)
 {
  String departmentNumber1 =String.valueOf(dept.dept2No__c);
  options.add(new selectOption(departmentNumber1,dept.name));
 }
 return options;
}
 
 public String getdepartmentNumber()
 {
 return departmentNumber;
 }
 public void setdepartmentNumber(String departmentNumber)
 {
 this.departmentNumber=departmentNumber;
 }
 public List<emp2__c> getemployees()
 {
  Id id=[select Id from dept2__c where dept2No__c=:departmentNumber].ID;
  employeesList=[select name,employeeId__c,  salary__c,Address__c from emp2__c where dept2No__c=:id];
  return employeesList;
 }
 public PageReference go()
 {
 return null;
 }
 }

 

visualpage: sx

 

 

<apex:page controller="departmentConrtroller">
<apex:form >
<apex:selectList value="{!departmentNumber}">
<apex:selectOptions value="{!departmentItems}"/>
</apex:selectList>
<apex:commandButton value="go" action="{!go}"/ >

</apex:form>
<apex:outputText value="{!employees}"/>
</apex:page>

hi am unable to resolve these issues  please  help me :

 

I have created two custome objects emp and dept1 , and i took master realation ship in employee table and related to dept1 table . when am able to write customer controller and visual page am getting following errors.

 

Error: Compile Error: unexpected token: '(' at line 13 column 70

public class SController
{
Integer departmentNumber;
List<emp__c> employees;
public Scontroller ()
{
employees=[select departmentNumber__c,id__c,sal__c,Name from emp__c where departmentNumber__c=:departmentNumber];
}
public Integer getDepartmentNumber()
 {
 return departmentNumber;
 }
public void setDepartmentNumber(ApexPages.currentPage.getParameter.get('departmentNumber'))
   {
   this.departmentNumber=ApexPages.currentPage.getParameter.get('departmentNumber');
   public List<emp__c>  getEmployees()
   {
   return employees;
   }
 public PageReference go()
  {
  return null;
  }
  }

 

 

 

ERROR: there is no SController Apex class Create: public class SController or create apex class public "sharing with" SController.

 

<apex:Page controller="SController">
<apex:form>
<apex:pageBlock title="employeeslist of current department">
<apex:pageBlockSection>
<apex:inputField value="{!dept1__c.number__c}" id="departmentNumber"/>
<apex:commandButton value="go" action="{!go}"

reRender="departmentNumber"/>
</apex:pageBlockSection>
<apex:pageBlockSection>
<apex:pageBlockTable title="current employees" value="{!employees}"

var="e">
<apex:column value="{!e.sal__c}"/>
<apex:column  value="{!e.id__c}"/>
<apex:column  value="{!e.Name}"/>
<apex:column  value="{!e.departmentNumber__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>