Exception in thread "main" java.lang.NullPointerException
at com.business.impl.MeteobussinesImpl.afficherMeteo1(MeteobussinesImpl.java:34)
at com.test.Tester.main(Tester.java:32)
1.Main Class
package com.test;
import java.util.Iterator;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.business.Meteobussines;
import com.business.impl.MeteobussinesImpl;
import com.model.vo.Meteo;
public class Tester {
static public void displayList(List list) {
Iterator iter = list.iterator();
if (!iter.hasNext()) {
System.out.println("La lsite est vide");
return;
}
while (iter.hasNext()) {
Meteo ct = (Meteo) iter.next();
System.out.println("tempsMax :" + ct.getTempMax() + " pays :" + ct.getLibilePays() + " distination :" + ct.getLibileDistination());
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] configArray = new String[]{"/com/resource/spring/ApplicationContext.xml",
"/com/resource/spring/ApplicationContextDao.xml", "/com/resource/spring/ApplicationContextBusiness.xml"};
ApplicationContext ctx = new ClassPathXmlApplicationContext(configArray);
Meteobussines mete = (Meteobussines) ctx.getBean("MeteoBuss");
List<Meteo> m = mete.afficherMeteo1("tounes");
displayList(m);
}
}
2.MeteoBussiness
package com.business.impl;
import java.util.Iterator;
import java.util.List;
import com.business.Meteobussines;
import com.dao.HistoriqueDao;
import com.dao.impl.HistoriqueDaoImpl;
import com.model.dto.Historique;
import com.model.vo.Meteo;
public class MeteobussinesImpl implements Meteobussines {
HistoriqueDao historiqueDao;
#SuppressWarnings("null")
#Override
public List<Meteo> afficherMeteo1(String pays) {
List<Historique> hiss = historiqueDao.rechercher(pays);
List<Meteo> m = null;
Iterator iter = hiss.iterator();
if (!iter.hasNext()) {
System.out.println("La lsite est vide");
}
while (iter.hasNext()) {
Historique ct = (Historique) iter.next();
Meteo me = new Meteo();
me.setDateHis(ct.getDateHis());
/*me.setLibileDistination(ct.getDistination().getLibileDis());
me.setLibilePays(ct.getPays().getLibilePays());
me.setLibileVille(ct.getVille().getLibileVille());*/
me.setTempMax(ct.getTempMax());
me.setTempMin(ct.getTempMin());
m.add(me);
}
return m;
// TODO Auto-generated method stub
}
#Override
public List<Meteo> afficherMeteo2(String pays, String ville) {
// TODO Auto-generated method stub
return null;
}
#Override
public List<Meteo> afficherMeteo3(String pays, String ville,
String distination) {
// TODO Auto-generated method stub
return null;
}
public HistoriqueDao getHistoriqueDao() {
return historiqueDao;
}
public void setHistoriqueDao(HistoriqueDao historiqueDao) {
this.historiqueDao = historiqueDao;
}
}
You set m to null on line 20, and then try to call a method on it on line 34 without ever assigning it a real value.
I think what you want to do on line 20 is initialize m as
List<Meteo> m = new ArrayList<Meteo>();
Related
This is what my recursion detector looks like (with an error of "The method contains(String) is undefined for Method Declaration" in if (md.contains(methodName))). I am not sure how I should change this to make it work. I hope to have some advice on what I could do to iterate through each individual method and check for its methodName in it. Thank you!
RecursionDetector.java
package detectors;
import java.awt.*;
import java.util.*;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
public class RecursionDetector extends VoidVisitorAdapter <Breakpoints> {
#Override
public void visit(MethodDeclaration md, Breakpoints collector) {
String className = getClass().getName();
String methodName = md.getName().asString();
int startline = md.getRange().get().begin.line;
int endline = md.getRange().get().end.line;
final StackTraceElement[] trace = Thread.currentThread().getStackTrace();
if (md.contains(methodName)) {
}
for (int i=0; i < trace.length-1; i++) {
if( trace[i].equals(trace[trace.length-1]) ) {
super.visit(md, collector);
collector.addEmpty(className, methodName, startline, endline);
}
}
}
}
I also have a Breakpoints.java that looks like this:
package detectors;
import java.util.ArrayList;
public class Breakpoints {
private ArrayList<String> collector = new ArrayList<String>();
public Breakpoints() { }
public void addClass(String currentClass) { }
public void addMethod(String currentMethod) { }
public ArrayList<String> returnCollector() {
return new ArrayList<String>(this.collector);
}
public void addEmpty(String currentClass, String currentMethod, int startLine, int endLine) {
String n = ("className: " + currentClass + ", methodName: " + currentMethod + ", startline : " + startLine
+ ", endline : " + endLine + "\n");
if (collector.contains(n)) {
return;
}
collector.add(n);
}
}
And a Driver.java that looks like this:
package detectors;
import java.io.*;
import java.util.Scanner;
import com.github.javaparser.*;
import com.github.javaparser.ast.CompilationUnit;
public class Driver {
public static String data;
public static String data2 = "";
public static void main(String[] args) {
try {
File myFile = new File("/Users/weihanng/Desktop/Calculator.java");
Scanner myReader = new Scanner(myFile);
while (myReader.hasNextLine()) {
data = myReader.nextLine();
data2 = data2.concat(data);
}
myReader.close();
CompilationUnit cu = JavaParser.parse(myFile);
Breakpoints collector = new Breakpoints();
cu.accept(new RecursionDetector(), collector);
System.out.println("Recursions: ");
System.out.println(collector.returnCollector());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
I have the following 3 Java classes which are supposed to emulate the Google page ranking algorithm:
Node.java
import java.util.ArrayList;
import java.util.List;
public class Node {
private String nodeDesc;
private List<String> inLinks;
private List<String> outLinks;
private float oldPageRank;
private float newPageRank;
public Node(String nodeDesc) {
super();
this.nodeDesc = nodeDesc;
inLinks = new ArrayList<String>();
outLinks = new ArrayList<String>();
}
public String getNodeDesc() {
return nodeDesc;
}
public void setNodeDesc(String nodeDesc) {
this.nodeDesc = nodeDesc;
}
public List<String> getInLinks() {
return inLinks;
}
public void setInLinks(List<String> inLinks) {
this.inLinks = inLinks;
}
public List<String> getOutLinks() {
return outLinks;
}
public void setOutLinks(List<String> outLinks) {
this.outLinks = outLinks;
}
public void setOutLink(String destDesc)
{
this.outLinks.add(destDesc);
}
public void setInLink(String srcDesc)
{
this.inLinks.add(srcDesc);
}
/**
* #return the oldPageRank
*/
public float getOldPageRank() {
return oldPageRank;
}
/**
* #param oldPageRank the oldPageRank to set
*/
public void setOldPageRank(float oldPageRank) {
this.oldPageRank = oldPageRank;
}
/**
* #return the newPageRank
*/
public float getNewPageRank() {
return newPageRank;
}
/**
* #param newPageRank the newPageRank to set
*/
public void setNewPageRank(float newPageRank) {
this.newPageRank = newPageRank;
}
}
Graph.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class Graph {
private Map<String, Node> nodes;
private static int length ;
private Graph() {
nodes = new HashMap<String, Node>();
}
public static Graph createGraph(File file,int forStartingPageRank) {
Graph graph = new Graph();
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String firstLine = reader.readLine();
float length=Float.parseFloat(firstLine.split(" ")[0]);
setLength((int)(length));
Float initialPageRank = null;
DecimalFormat df = new DecimalFormat("#.000000");
switch (forStartingPageRank) {
case 0:
initialPageRank=Float.parseFloat(df.format(0));
break;
case 1:
initialPageRank=Float.parseFloat(df.format(1));
break;
case -1:
initialPageRank=Float.parseFloat(df.format(1/length));
break;
case -2:
initialPageRank=Float.parseFloat(df.format(1/Math.sqrt(length)));
break;
default:
break;
}
String edge;
int i = 0;
while ((edge = reader.readLine()) != null) {
String[] nodePair = edge.split(" ");
String srcDesc = nodePair[0];
String destDesc = nodePair[1];
Node srcNode = graph.getNode(srcDesc);
if (srcNode == null) {
srcNode = new Node(srcDesc);
srcNode.setOutLink(destDesc);
srcNode.setOldPageRank(initialPageRank);
graph.nodes.put(srcDesc, srcNode);
} else {
srcNode.setOutLink(destDesc);
}
Node destNode = graph.getNode(destDesc);
if (destNode == null) {
destNode = new Node(destDesc);
destNode.setInLink(srcDesc);
destNode.setOldPageRank(initialPageRank);
graph.nodes.put(destDesc, destNode);
} else {
destNode.setInLink(srcDesc);
}
}
reader.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return graph;
}
public Map<String, Node> getNodes() {
return nodes;
}
public Node getNode(String nodeDesc) {
return nodes.get(nodeDesc);
}
public void display(int forItration)
{
TreeMap<String, Node> treeMap = new TreeMap<String, Node>(nodes);
Iterator<String> i = treeMap.keySet().iterator();
int j =1;
float sum = 0f;
DecimalFormat df1 = new DecimalFormat("#.000000");
//df.setMaximumFractionDigits(6);
int p;
if(forItration== 0){
p=999;
}else{
p=forItration;
}
float temp = nodes.get(i.next()).getOldPageRank();
System.out.print("Base\t : 0"+" :");
for(Map.Entry<String,Node> entry : treeMap.entrySet()) {
String key = entry.getKey();
Node node = nodes.get(key);
System.out.print("P["+node.getNodeDesc()+"] = "+df1.format(temp) +" ");
}
System.out.println();
while(j<=p){
if(j<=9){
System.out.print("Iter\t : 0"+j+" :");
}else{
System.out.print("Iter\t : "+j+" :");
}
for(Map.Entry<String,Node> entry : treeMap.entrySet()) {
String key = entry.getKey();
sum =0f;
Node node = nodes.get(key);
//System.out.println("Inlinks : "+node.getInLinks());
List<String> inLinkNodes = node.getInLinks();
for (String inLinkNode : inLinkNodes) {
Node tempNode = nodes.get(inLinkNode);
sum=sum+(tempNode.getOldPageRank()/tempNode.getOutLinks().size());
}
float newPageRank = 0.0375f+0.85f*(sum);
node.setNewPageRank(Float.parseFloat(df1.format(newPageRank)));
System.out.print("P["+node.getNodeDesc()+"] = "+df1.format(newPageRank) +" ");
}
System.out.println();
j++;
int m=0;
for(Map.Entry<String,Node> entry : treeMap.entrySet()) {
String key = entry.getKey();
sum =0f;
Node node = nodes.get(key);
if(node.getOldPageRank()-node.getNewPageRank()<0.0001){
m++;
}
node.setOldPageRank(node.getNewPageRank());
}
if(m==getLength() && forItration == 0){
break;
}
}
}
/**
* #return the length
*/
public static int getLength() {
return length;
}
/**
* #param length the length to set ---git
*/
public static void setLength(int length) {
Graph.length = length;
}
}
GraphCreator.java
import java.io.File;
import java.text.DecimalFormat;
public class GraphCreator {
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int forItration =-9;
int forStartingPageRank=-9;
String fileName = null;
if(args.length!=3){
System.out.println("Please pass Three argument ...");
System.exit(0);
}
try{
forItration = Integer.parseInt(args[0]);
forStartingPageRank = Integer.parseInt(args[1]);
fileName = args[2];
}catch(NumberFormatException nfe){
System.out.println("Invalid Arguments ...");
System.exit(0);
}
System.out.println("Creating Graph..");
Graph graph = Graph.createGraph(new File(fileName),forStartingPageRank);//"nodes.txt"
System.out.println("Graph created.");
graph.display(forItration);
//System.out.println(graph.getNodes());
}
}
I have compiled all 3, however I've gone through numerous websites that address this issue and none seem to work. Is there an issue with how GraphCreator.java references the other classes?
I have set up a java class that I want to use for an xe:beanNamePicker. Somehow I am not able to add a created SimplePickerResult into the result set.
package se.myorg.myproject.app;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.TreeSet;
import se.sebank.namis.utils.Utils;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.DocumentCollection;
import lotus.domino.NotesException;
import lotus.domino.View;
import com.ibm.xsp.complex.ValueBindingObjectImpl;
import com.ibm.xsp.extlib.component.picker.data.INamePickerData;
import com.ibm.xsp.extlib.component.picker.data.IPickerEntry;
import com.ibm.xsp.extlib.component.picker.data.IPickerOptions;
import com.ibm.xsp.extlib.component.picker.data.IPickerResult;
import com.ibm.xsp.extlib.component.picker.data.SimplePickerResult;
public class DirectoryNamePicker extends ValueBindingObjectImpl implements INamePickerData {
private Utils utils;
Properties props;
public DirectoryNamePicker(){
//constructor
utils = new Utils();
utils.printToConsole(this.getClass().getSimpleName().toString() + " - DirectoryNamePicker() // constructor");
try {
props = utils.getDataSourceProperties();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String[] getSourceLabels () {
// TODO Auto-generated method stub
return null;
}
public boolean hasCapability (final int arg0) {
// TODO Auto-generated method stub
return false;
}
public List<IPickerEntry> loadEntries (final Object[] arg0, final String[] arg1) {
// TODO Auto-generated method stub
return null;
}
#SuppressWarnings("unchecked")
public IPickerResult readEntries (final IPickerOptions options) {
String startKey = options.getStartKey();
int count = options.getCount();
TreeSet<IPickerEntry> entries = new TreeSet<IPickerEntry>();
if (startKey != null) {
// User is performing a search
try {
entries = this.dirLookup(startKey, count);
} catch (NotesException e) {
System.err.println("Exception trying to perform directory lookup: " + e.getMessage());
e.printStackTrace();
}
}
return new SimplePickerResult((List<IPickerEntry>) entries, -1);
}
public TreeSet<IPickerEntry> dirLookup(final String search, final int limit) throws NotesException {
TreeSet<IPickerEntry> result = new TreeSet<IPickerEntry>();
String server = props.getProperty("server_notesname");
String filepath = props.getProperty("db_project_data");
Database db = utils.getSession().getDatabase(server, filepath);
View vw = db.getView("vw_all_todo_namespicker");
vw.setAutoUpdate(false);
DocumentCollection dc = vw.getAllDocumentsByKey(search, false);
int count = 0;
Document tmpdoc;
Document doc = dc.getFirstDocument();
while (doc != null && count < limit) {
String person = doc.getItemValueString("app_ProjMgrName");
IPickerEntry entry = new SimplePickerResult.Entry(person, person);
result.add(entry);
// result.add(entry does not seem to work
tmpdoc = dc.getNextDocument();
doc.recycle();
doc = tmpdoc;
count = count +1;
}
vw.setAutoUpdate(true);
return result;
}
}
Is there anyone that can tell me what I m doing wrong? I have choosen a treeset instead of an arraylist. this is because I go to a view with lots of multiple entries so I do not want duplicates and have it sorted by values.
You're casting TreeSet to (List) at the line:
return new SimplePickerResult((List<IPickerEntry>) entries, -1);
because the SimplePickerResult needs a List (it won't accept a Collection), but TreeSet does not implement List, so that cast will fail.
You'll probably have to change it back to an ArrayList.
To sort, try using java.util.Collections.sort(List list, Comparator c) with a custom comparator that compares the entry.getLabel() value, as SimplePickerResult.Entry doesn't have an in-built compare method.
I have class A,B and Main
Class A uses class B, and main uses class A
I want to run those files with the command line
I done:
javac *.java
java Main
And then i get Error: Could not find or load main class Main.
Code:
Location.java
package hw3;
public class Location {
private int objectLength;
private long byteLocation;
public Location(int freshLength, long freshLocation)
{
objectLength = freshLength;
byteLocation = freshLocation;
}
public int getLength()
{
return objectLength;
}
public long getLocation()
{
return byteLocation;
}
}
FileMap.java
package hw3;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class FileMap<K, V extends Serializable> implements Map<K, V>{
private HashMap<K, Location> database; // Used to hold a key and the value location and length
File fp;
RandomAccessFile s;
public FileMap(String filename) throws FileNotFoundException
{
database = new HashMap<K, Location>();
fp = new File(filename);
s = new RandomAccessFile(fp, "rws");
}
public void closeFile()
{
try {
s.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public byte[] serialize(V value) throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(value);
return baos.toByteArray();
}
#SuppressWarnings("unchecked")
public V deserialize(byte[] byteArray) throws IOException, ClassNotFoundException
{
ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(bais);
return (V)ois.readObject();
}
#Override
public void clear() {
// TODO Auto-generated method stub
}
#Override
public boolean containsKey(Object key) {
if(database.containsKey(key)) return true;
return false;
}
#Override
public boolean containsValue(Object value) {
// TODO Auto-generated method stub
return false;
}
#Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
// TODO Auto-generated method stub
return null;
}
#Override
public V get(Object key) {
if(database.containsKey(key))
{
try
{
byte[] bar = new byte[database.get(key).getLength()]; // Create a byteArray long enough to hold the object
s.seek((int)database.get(key).getLocation()); // Move file pointer to saved value location
s.read(bar, 0, database.get(key).getLength()); // Read object
try
{
return deserialize(bar); // "Un-flatten" object and return it
}
catch (ClassNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
catch (IOException e)
{
System.err.println("Couldn't read file");
e.printStackTrace();
}
}
return null;
}
#Override
public boolean isEmpty() {
if(database.isEmpty()) return true;
return false;
}
#Override
public Set<K> keySet() {
// TODO Auto-generated method stub
return null;
}
#Override
public V put(K key, V value) {
if(!database.containsKey(key))
{
try
{
byte[] ba = serialize(value); // "flatten" object to byte array
s.seek(s.length()); // Go to end of file
s.write(ba); // Write byte array to end of file
database.put(key, new Location(ba.length,s.length()-ba.length)); // Save key in internal key-location map
} catch (IOException e) {
e.printStackTrace();
}
}
else
{
System.out.println("Key already exists");
}
return null;
}
#Override
public void putAll(Map<? extends K, ? extends V> m) {
// TODO Auto-generated method stub
}
#Override
public V remove(Object key) {
// TODO Auto-generated method stub
return null;
}
#Override
public int size() {
return database.size();
}
#Override
public Collection<V> values() {
// TODO Auto-generated method stub
return null;
}
}
Main.java
package hw3;
import java.io.FileNotFoundException;
public class Main {
public static void main(String[] args) {
String fileName = "/home/rippxe/Documents/S2/Java/hw3/randFile.bin";
Integer x1 = new Integer(152), x2 = new Integer(485), x3 = new Integer(825);
String str1 = "bob",str2 = "john",str3 = "steve";
FileMap<Integer, String> fm = null;
try
{
fm = new FileMap<Integer, String>(fileName);
}
catch(FileNotFoundException fnfe)
{
System.err.println("File not found");
}
fm.put(x1, str1);
fm.put(x2, str2);
fm.put(x3, str3);
String new1 = fm.get(x1);
String new2 = fm.get(x2);
String new3 = fm.get(x3);
System.out.println(new1 + " " + x1 + "\n"+ new2 + " " +x2 +"\n"+ new3 + " " +x3);
fm.closeFile();
}
}
I have added the code of my classes, which you can see above.
Thanks
I'm getting this warning from #PostConstruct annotated init method
Nis 18, 2014 2:46:10 PM com.sun.faces.vendor.WebContainerInjectionProvider getAnnotatedMethodForMethodArr
WARNING: JSF1047: Method 'public void com.revir.managed.bean.PickListBean.init() throws java.lang.Exception' marked with the 'javax.annotation.PostConstruct' annotation cannot declare any checked exceptions. This method will be ignored.
So my method is ignored, what do I have to do to fix this problem ?
package com.revir.managed.bean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.TransferEvent;
import org.primefaces.model.DualListModel;
import org.springframework.beans.factory.annotation.Autowired;
#ManagedBean(name = "pickListBean")
#ViewScoped
public class PickListBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private DualListModel<TrvrTani> tanis;
private DualListModel<TrvrIlac> ilacs;
int tanisize = 0;
String taniadi = null;
Long taniidp = null;
public Long getTaniidp() {
return taniidp;
}
public void setTaniidp(Long taniidp) {
this.taniidp = taniidp;
}
String tanikodu = null;
#Autowired(required=false)
private TrvrTaniDAO tanidao;
public TrvrTaniDAO getTanidao() {
return tanidao;
}
public void setTanidao(TrvrTaniDAO tanidao) {
this.tanidao = tanidao;
}
List<TrvrTani> sourcetani;
List<TrvrTani> targettani;
List<TrvrIlac> sourceilac;
List<TrvrIlac> targetilac;
#PostConstruct
public void init(){
try {
sourcetani = new ArrayList<TrvrTani>();
targettani = new ArrayList<TrvrTani>();
tanidao = new TrvrTaniDAO();
List<TrvrTani> taniList = tanidao.findAll();
for (TrvrTani tani : taniList) {
Long taniid = tani.getTaniid();
sourcetani.add(new TrvrTani(taniid, tani.getTaniadi(), tani
.getTanikodu()));
}
tanis = new DualListModel<TrvrTani>(sourcetani, targettani);
sourceilac = new ArrayList<TrvrIlac>();
targetilac = new ArrayList<TrvrIlac>();
ilacdao = new TrvrIlacDAO();
List<TrvrIlac> ilacList = ilacdao.findAll();
for (TrvrIlac ilac : ilacList) {
sourceilac.add(new TrvrIlac(ilac.getIlacid(), ilac.getIlacad(),
ilac.getBarkod(), null));
}
ilacs = new DualListModel<TrvrIlac>(sourceilac, targetilac);
} catch (Exception e) {
System.out.println("Hata mesajı : " +e);
throw e;
}
}
public DualListModel<TrvrIlac> getIlacs() {
return ilacs;
}
public void setIlacs(DualListModel<TrvrIlac> ilacs) {
this.ilacs = ilacs;
}
public DualListModel<TrvrTani> getTanis() {
return tanis;
}
public void setTanis(DualListModel<TrvrTani> tanis) {
this.tanis = tanis;
}
public void onTransferTani(TransferEvent event) {
StringBuilder builder = new StringBuilder();
for (Object item : event.getItems()) {
builder.append(((TrvrTani) item).getTaniadi()).append("<br />");
targetlist(tanisize, taniadi, taniidp, tanikodu);
}
FacesMessage msgtani = new FacesMessage();
msgtani.setSeverity(FacesMessage.SEVERITY_INFO);
msgtani.setSummary("Tanı Eklendi");
msgtani.setDetail(builder.toString());
FacesContext.getCurrentInstance().addMessage(null, msgtani);
}
public void targetlist(int tanisize, String taniadi, Long taniidp,
String tanikodu) {
tanisize = tanis.getTarget().size();
System.out.println(" ************target************* : "
+ tanis.getTarget().size());
for (int h = 0; h < tanisize; h++) {
/* elemanin adi, id si ve kodu */
taniadi = tanis.getTarget().get(h).getTaniadi();
System.out.println(" ************taniadi1************* : "
+ taniadi);
taniidp = tanis.getTarget().get(h).getTaniid();
System.out.println(" ************taniid2************* : "
+ taniidp);
tanikodu = tanis.getTarget().get(h).getTanikodu();
System.out.println(" ************tanikodu3************* : "
+ tanikodu);
}
}
public void onTransferIlac(TransferEvent event) {
StringBuilder builder = new StringBuilder();
for (Object item : event.getItems()) {
builder.append(((TrvrIlac) item).getIlacad()).append("<br />");
}
FacesMessage msgilac = new FacesMessage();
msgilac.setSeverity(FacesMessage.SEVERITY_INFO);
msgilac.setSummary("İlaç Eklendi");
msgilac.setDetail(builder.toString());
FacesContext.getCurrentInstance().addMessage(null, msgilac);
}
}
Remove the throws Exception from the init method. Use try catch to prevent any exception from being thrown. Once you remove the exception declaration, the compiler will show you of any exceptions that may be thrown, so add try catch there.