You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Madtyn <ma...@gmail.com> on 2009/09/05 02:26:51 UTC
Why does this fail???
Hello. I keep trying to use the EventContext and made some advances.
As Joshua said the enums can be sent between the onPassivate and
onActivate methods (Thank you Joshua :).
But the problem is that I keep finding very strange problems. I
have isolated the piece of code that is giving me hell. I'm passing
two enums to the onActivate and I do inside two nested switch, but it
always fails when trying to read the value of the second enum at the
second switch and gives the classic:
java.lang.VerifyError Illegal constant pool index
And the stacktrace leads to the line where I first set an attribute
to the destiny page.
If I comment the second switch, the code works, but I need to work
with the value of the enum (that's why I'm passing it).
As I don't know if I'm allowed to send attached files, I copy the
abbreviated code down here. Sorry if it bothers. The code problem is
at the deep bottom. Getters and setters are omitted. Thanks on
advance.
public class FindSocios {
@Property
private Long idSocio, idServ;
@Property
private Date date1=null, date2=null;
@Property
private String apellidos, login, dni;
private SocioSearchType socioSearchType = SocioSearchType.ALL;
private DateSearchType dateSearchType=DateSearchType.BYNODATE;
private CatType catSearchType = CatType.ADULTO;
@InjectPage
private FindSocios refresh;
@InjectPage
private ShowSocios showSocios;
@InjectPage
private InfoSocio infoSocio;
Object[] onPassivate() {
if(busqueda) {
return new Object[] {socioSearchType, dateSearchType};
}
else return null;
}
// Necesario para cuando la pagina muestra el segundo formulario
void onActivate(EventContext ev) {
if(ev.getCount()==2)
socioSearchType = ev.get(SocioSearchType.class, 0);
dateSearchType = ev.get(DateSearchType.class, 1);
}
Object onSuccess() throws ParseException {
if(busqueda) {
busqueda = false;
infoSocio.setSocioSearchType(socioSearchType);
infoSocio.setDateSearchType(dateSearchType);
showSocios.setSocioSearchType(socioSearchType);
switch(socioSearchType) {
case BYAPELL:
showSocios.setApellidos(apellidos);
return showSocios;
case BYSERVICIO:
showSocios.setIdServ(idServ);
return showSocios;
case BYCATEGORIA:
showSocios.setCatSearchType(catSearchType);
return showSocios;
case HISTORY:
showSocios.setIdSocio(idSocio);
return showSocios;
case BYLOGIN:
infoSocio.setLogin(login);
return infoSocio;
case BYDNI:
infoSocio.setDni(dni);
return infoSocio;
case BYID:
infoSocio.setIdSocio(idSocio);
return infoSocio;
case ALL:
switch(dateSearchType) {
case BYDATE:
showSocios.setDateSearchType(dateSearchType);
showSocios.setDate1(DateHandler.dateToSendFormat(date1));
return showSocios;
case BYDATES:
showSocios.setDateSearchType(dateSearchType);
showSocios.setSocioSearchType(socioSearchType);
showSocios.setDate1(DateHandler.dateToSendFormat(date1));
showSocios.setDate2(DateHandler.dateToSendFormat(date2));
return showSocios;
}
default: return null;
}
}
return null;
}
}
/* Now, the destiny page */
public class ShowSocios {
@Property
private final int SOCIOS_PER_PAGE=10;
private SocioSearchType socioSearchType;
private DateSearchType dateSearchType;
private CatType catSearchType;
private int startIndex=0;
@Property
private SocioInfo info;
private Block<SocioInfo> infos;
private Long idSocio, idServ;
private Date date1, date2;
private String apellidos, dni, login;
@Property
private Socio socio;
@Inject
private GimnasioService gimnasioService;
@Inject
private Locale locale;
Object onPassivate() {
switch(socioSearchType) {
case BYAPELL: return new Object[] {socioSearchType, apellidos};
case BYCATEGORIA: return new Object[] {socioSearchType, catSearchType};
case BYSERVICIO: return new Object[] {socioSearchType,idServ};
case HISTORY: return new Object[] {socioSearchType,idSocio};
case ALL:
switch(dateSearchType) {
case BYNODATE: return new Object[] {socioSearchType, dateSearchType};
case BYDATE: return new Object[] {socioSearchType, dateSearchType, date1};
case BYDATES: return new Object[] {socioSearchType,
dateSearchType, date1, date2};
}
default: return new Object[] {};
}
}
void onActivate(EventContext ev) throws InstanceNotFoundException {
System.out.println(ev.getCount()+" = "+ev.get(SocioSearchType.class,
0).toString()+"; "+ev.get(String.class, 1));
socioSearchType = ev.get(SocioSearchType.class, 0);
switch(socioSearchType) {
case BYAPELL:
apellidos = ev.get(String.class, 1);
infos = gimnasioService.findSociosByApell(apellidos, startIndex,
SOCIOS_PER_PAGE);
break;
case BYCATEGORIA:
catSearchType = ev.get(CatType.class, 1);
infos = gimnasioService.findEstSocios("categoria.idCategoria",
catSearchType.getId(), null, null, startIndex, SOCIOS_PER_PAGE);
break;
case HISTORY:
idSocio = ev.get(Long.class, 1);
infos = gimnasioService.histSocio(idSocio, startIndex, SOCIOS_PER_PAGE);
break;
case BYSERVICIO:
idServ = ev.get(Long.class, 1);
infos = gimnasioService.findActualSociosByConv(idServ, startIndex,
SOCIOS_PER_PAGE);
break;
case ALL:
infos=gimnasioService.findEstSocios(null, null, null, null,
startIndex, SOCIOS_PER_PAGE);
dateSearchType = ev.get(DateSearchType.class, 1);
/* THIS IS THE DANGEROUS CODE THAT BREAKS EVERYTHING */
/*switch(dateSearchType) {
case BYNODATE:
break;
case BYDATE:
break;
case BYDATES:
break;
}*/
break;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Why does this fail???
Posted by Madtyn <ma...@gmail.com>.
I forgot I posted this problem. Yes, you're right and I solved the
problem changing the switch and inserting and if-else if structure
instead. I was really confused about the same variable causing an
error being used in different ways of making the same thing (retrieve
the value), but now with the Javassist issue I understand the whole
thing.
Thanks, Thiago.
2009/9/7 Thiago H. de Paula Figueiredo <th...@gmail.com>:
> Howard once said that sometimes Javassist (used by Tapestry to
> transform classes) sometimes doesn't handle large event handler
> methods correctly. Try refactoring your method to reduce it. By the
> way, a switch inside a switch is not recommended coding: refactor it
> too. ;)
>
> --
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Why does this fail???
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Howard once said that sometimes Javassist (used by Tapestry to
transform classes) sometimes doesn't handle large event handler
methods correctly. Try refactoring your method to reduce it. By the
way, a switch inside a switch is not recommended coding: refactor it
too. ;)
--
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Why does this fail???
Posted by Alfonso Quiroga <al...@gmail.com>.
I'm from a Spanish language country and I want to correct something:
/* Now, the destiny page */ is:
/* Now, the TARGET page */
On Fri, Sep 4, 2009 at 9:26 PM, Madtyn<ma...@gmail.com> wrote:
> Hello. I keep trying to use the EventContext and made some advances.
> As Joshua said the enums can be sent between the onPassivate and
> onActivate methods (Thank you Joshua :).
>
>
> But the problem is that I keep finding very strange problems. I
> have isolated the piece of code that is giving me hell. I'm passing
> two enums to the onActivate and I do inside two nested switch, but it
> always fails when trying to read the value of the second enum at the
> second switch and gives the classic:
>
> java.lang.VerifyError Illegal constant pool index
>
> And the stacktrace leads to the line where I first set an attribute
> to the destiny page.
>
> If I comment the second switch, the code works, but I need to work
> with the value of the enum (that's why I'm passing it).
>
> As I don't know if I'm allowed to send attached files, I copy the
> abbreviated code down here. Sorry if it bothers. The code problem is
> at the deep bottom. Getters and setters are omitted. Thanks on
> advance.
>
>
>
> public class FindSocios {
>
> @Property
> private Long idSocio, idServ;
>
> @Property
> private Date date1=null, date2=null;
>
> @Property
> private String apellidos, login, dni;
>
> private SocioSearchType socioSearchType = SocioSearchType.ALL;
> private DateSearchType dateSearchType=DateSearchType.BYNODATE;
> private CatType catSearchType = CatType.ADULTO;
>
> @InjectPage
> private FindSocios refresh;
>
> @InjectPage
> private ShowSocios showSocios;
>
> @InjectPage
> private InfoSocio infoSocio;
>
> Object[] onPassivate() {
> if(busqueda) {
> return new Object[] {socioSearchType, dateSearchType};
> }
> else return null;
> }
>
>
> // Necesario para cuando la pagina muestra el segundo formulario
> void onActivate(EventContext ev) {
> if(ev.getCount()==2)
> socioSearchType = ev.get(SocioSearchType.class, 0);
> dateSearchType = ev.get(DateSearchType.class, 1);
>
> }
> Object onSuccess() throws ParseException {
> if(busqueda) {
>
> busqueda = false;
>
> infoSocio.setSocioSearchType(socioSearchType);
> infoSocio.setDateSearchType(dateSearchType);
> showSocios.setSocioSearchType(socioSearchType);
> switch(socioSearchType) {
> case BYAPELL:
> showSocios.setApellidos(apellidos);
> return showSocios;
> case BYSERVICIO:
> showSocios.setIdServ(idServ);
> return showSocios;
> case BYCATEGORIA:
> showSocios.setCatSearchType(catSearchType);
> return showSocios;
> case HISTORY:
> showSocios.setIdSocio(idSocio);
> return showSocios;
> case BYLOGIN:
> infoSocio.setLogin(login);
> return infoSocio;
> case BYDNI:
> infoSocio.setDni(dni);
> return infoSocio;
> case BYID:
> infoSocio.setIdSocio(idSocio);
> return infoSocio;
> case ALL:
> switch(dateSearchType) {
> case BYDATE:
> showSocios.setDateSearchType(dateSearchType);
> showSocios.setDate1(DateHandler.dateToSendFormat(date1));
> return showSocios;
> case BYDATES:
> showSocios.setDateSearchType(dateSearchType);
> showSocios.setSocioSearchType(socioSearchType);
> showSocios.setDate1(DateHandler.dateToSendFormat(date1));
> showSocios.setDate2(DateHandler.dateToSendFormat(date2));
> return showSocios;
> }
> default: return null;
> }
> }
> return null;
>
> }
>
> }
>
>
> /* Now, the destiny page */
>
> public class ShowSocios {
>
> @Property
> private final int SOCIOS_PER_PAGE=10;
>
> private SocioSearchType socioSearchType;
> private DateSearchType dateSearchType;
> private CatType catSearchType;
>
> private int startIndex=0;
>
> @Property
> private SocioInfo info;
> private Block<SocioInfo> infos;
>
>
> private Long idSocio, idServ;
> private Date date1, date2;
> private String apellidos, dni, login;
>
> @Property
> private Socio socio;
>
> @Inject
> private GimnasioService gimnasioService;
>
> @Inject
> private Locale locale;
>
> Object onPassivate() {
> switch(socioSearchType) {
> case BYAPELL: return new Object[] {socioSearchType, apellidos};
> case BYCATEGORIA: return new Object[] {socioSearchType, catSearchType};
> case BYSERVICIO: return new Object[] {socioSearchType,idServ};
> case HISTORY: return new Object[] {socioSearchType,idSocio};
> case ALL:
> switch(dateSearchType) {
> case BYNODATE: return new Object[] {socioSearchType, dateSearchType};
> case BYDATE: return new Object[] {socioSearchType, dateSearchType, date1};
> case BYDATES: return new Object[] {socioSearchType,
> dateSearchType, date1, date2};
> }
> default: return new Object[] {};
> }
> }
>
> void onActivate(EventContext ev) throws InstanceNotFoundException {
> System.out.println(ev.getCount()+" = "+ev.get(SocioSearchType.class,
> 0).toString()+"; "+ev.get(String.class, 1));
>
> socioSearchType = ev.get(SocioSearchType.class, 0);
>
> switch(socioSearchType) {
> case BYAPELL:
> apellidos = ev.get(String.class, 1);
> infos = gimnasioService.findSociosByApell(apellidos, startIndex,
> SOCIOS_PER_PAGE);
> break;
> case BYCATEGORIA:
> catSearchType = ev.get(CatType.class, 1);
> infos = gimnasioService.findEstSocios("categoria.idCategoria",
> catSearchType.getId(), null, null, startIndex, SOCIOS_PER_PAGE);
> break;
> case HISTORY:
> idSocio = ev.get(Long.class, 1);
> infos = gimnasioService.histSocio(idSocio, startIndex, SOCIOS_PER_PAGE);
> break;
> case BYSERVICIO:
> idServ = ev.get(Long.class, 1);
> infos = gimnasioService.findActualSociosByConv(idServ, startIndex,
> SOCIOS_PER_PAGE);
> break;
> case ALL:
> infos=gimnasioService.findEstSocios(null, null, null, null,
> startIndex, SOCIOS_PER_PAGE);
> dateSearchType = ev.get(DateSearchType.class, 1);
>
> /* THIS IS THE DANGEROUS CODE THAT BREAKS EVERYTHING */
> /*switch(dateSearchType) {
> case BYNODATE:
> break;
> case BYDATE:
> break;
> case BYDATES:
> break;
> }*/
> break;
> }
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>