how is said in the title I can not to resolve this problem for several hours. I hope I will get some useful replies, thank you.
wicket version: 1.5.7
public class EvalSearcherPage extends MenuPage {
...
private Code selectedEvalChoice;
...
...
RadioChoice<Code> evalRadioChoice = new RadioChoice<Code>("evalRadioChoice", new PropertyModel<Code>(this, "selectedEvalChoice"), EVAL_CHOICES, new ChoiceRenderer<Code>(getLocaleColumn()));
evalRadioChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = 1L;
#Override
protected void onUpdate(AjaxRequestTarget target) {
...
target.add(...);
}
});
evalChoiceForm.add(evalRadioChoice);
...
in constructor:
EVAL_CHOICES is filled by choices,
selectedEvalChoice is filled by default choice
Everything works good till the moment when I want to select another choice. After that RadioChoice saves null to selectedEvalChoice.
So where is the problem, could anybody help, please?
Btw getter and setter are implemented for selectedEvalChoice but I learned that is not necessary.
For RadioChoice you have to use AjaxForm*Choice*ComponentUpdatingBehavior.
Check your log output, you should find a warning there.
Related
I have an issue when I compile the user interface, when i add a method messages.usuario(), Firebug show the error : TypeError: null has no properties
lblUsuario = new Label_2(null.nullMethod()); this is the code of my class :
public class AdministradorMVP implements EntryPoint {
private MessageConstants messages;
#Inject
public void setMensajes(MessageConstants mensajes) {
this.messages = mensajes;
}
private final MyWidgetGinjector injector = GWT.create(MyWidgetGinjector.class);
private Place defaultPlace = new SignInPlace("Admin");
private SimplePanel appWidget = new SimplePanel();
/**
* This is the entry point method.
*/
Label lblUsuario = new Label(messages.usuario());
Label lblNombre = new Label(messages.nombre());
so I can't find the source of the problem, thank you
The GWT compiler generates null.nullMethod() whenever it can statically determine that a particular method is always called on a null reference. In this case, messages has been determined to always be null (either setMensajes is called with a null value or it's not called at all), so messages.usuario() would always throw a NullPointerException, and this is translated into a null.nullMethod() in the generated JavaScript code.
From your code I'm missing the 'boostrap the injection' (see JavaDoc of Ginjector). In other words, you need to trigger the initial inject to take place. Creating MyWidgetGinjector is not enough.
One solution is to add a method void inject(AdministradorMVP entryPoint); to the interface MyWidgetGinjector and in the class AdministradorMVP in onModuleLoad call as (one of) the first statements: injector.inject(this);.
I apologize in advance, admittedly I lack understanding in Wicket.
I read that using LoadableDetachableModel will prevent the object from being serialized, but after running the test several times I could see that it still gets serialized (after session timeout or on page load after timeout, sometimes). I think maybe I am not using models correctly. Any help or direction would be greatly appreciated.
the code looks like this:
...
LoadableDetachableModel ldm = new LoadableDetachableModel<SomeSettings>() {
#Override
public SomeSettings load() {
if (someSettingsDao == null) someSettingsDao = new SomeSettingsDao();
return someSettingsDao.Retrieve("1") == null ? new SomeSettings()
: (SomeSettings) someSettingsDao.Retrieve("1");
}
};
final Form<SomeSettings> form = new Form<SomeSettings>("someSettings", new CompoundPropertyModel<SomeSettings>(ldm)) {
private static final long serialVersionUID = 1L;
#Override
protected void onSubmit() {
if (someSettingsDao == null) someSettingsDao = new SomeSettingsDao();
if (someSettingsDao.Retrieve("1") != null)
someSettingsDao.Update(getModelObject());
else
someSettingsDao.Insert(getModelObject());
setResponsePage(UserPanel.someSettingsPageProvider.getPageClass());
}
};
...
Is it my use of models? Or how the data is persisted?
Thanks.
You are right. Data are persisted/serialized when Wicket decides to persist. After a component/page is rendered all components and models are detached. It means loadable detachable model detaches its inner model and there is nothing to be serialized. Of course serialization is made ever after page is rendered and it is not necessarry to keep it in memory.
I've been losing my mind over this for the past week. I've tried tons of tutorials and forums, but nothing works.
Here's the overview: I want to display JavaBean objects in a simple table. I've created the JavaBean object, I've set the classpath, but iReport just won't work with it no matter what I try. Here's the entire Java code:
package mypack;
public class Person
{
private String name;
private static Person[] data = {new Person("John"), new Person("Mark")};
public Person() {}
public Person(String newName) { name = newName; }
public String getName() { return name; }
public void setName(String newName) { name = newName; }
public static Person[] getPersons() { return data; }
}
In iReport, I've created a new "JavaBeans set datasource" connection. Here's how it's filled:
However, when I click on "Test", nothing at all happens. No error but no data either. If Ichange the name of the factory class, then I will get the "class not found" exception, so iReport obviously did load my class, but it's still not working.
I really have no idea what I'm doing wrong in the Java file, because iReport seems to load it fine, but can't "talk" with it.
I've created the Java class with Eclipse Juno and I'm using iReport 4.6.0. Any help woud be really appreciated.
Problem solved. I was building Java file against 1.7, which iReports can't seem to read it seems. Building for 1.6 solves the problem and the above code works fine.
I just come from my tiny nice JavaSE/Guice world and am currently discovering the path of "carried by the container"-EE6. After having some trouble with Glassfish3.1, I just switched to JBoss and am now facing a problem that shouldnt be one.
As infrastructural assisting class, im trying to create a generic repository/DAO for any kind of entity. In a very simple manner, this might look like this one.
public class Repository<E, K extends Serializable & Comparable<K>> {
private final Instance<EntityManager> entityManagerInstance;
protected final Class<E> getDomainObjectClass() {
return domainObjectClass;
}
private final Class<E> domainObjectClass;
protected final EntityManager getEntityManager() {
return entityManagerInstance.get();
}
#Inject
public Repository(Instance<EntityManager> entityManageryProvider, Provider<E> domainObjectProvider) {
//This is a dirty hack, sadly :(
domainObjectClass = (Class<E>)domainObjectProvider.get().getClass();
this.entityManagerInstance = entityManageryProvider;
}
public final void persist(E domainObject) {
final EntityManager em = getEntityManager();
em.persist(domainObject);
}
public final Collection<E> getAllEntities() {
final EntityManager em = getEntityManager();
final CriteriaBuilder cb = em.getCriteriaBuilder();
final CriteriaQuery<E> query = cb.createQuery(getDomainObjectClass());
final List<E> result = em.createQuery(query).getResultList();
return Collections.unmodifiableList(result);
}
public final E find(K id) {
Preconditions.checkNotNull(id);
final EntityManager em = getEntityManager();
return em.find(getDomainObjectClass(), id);
}
// [...]
}
Now there may be a bean that does not require entity-dependent query capabilities but just a repository of a certain entity type, like (might be a test case):
public class DomainObjectARepositoryTest{
#Inject
Repository<DomainObjectA, PersistableUUID> domainObjectARepository;
#Test
public void testMitarbeitererstellung() {
for (DomainObjectA a : domainObjectARepository.getAllEntities()) {
// do cool stuff
}
}
}
Unfortunatly Weld does not seem to like this kind of generic injection. At deployment time, I get the following error:
state=Create: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Repository<DomainObjectA , PersistableUUID>] with qualifiers [#Default] at injection point [[field] #Inject sompackage.DomainObjectARepositoryTest.domainObjectARepository]
Am I missing something or did they just forgot to implement generic injects? As far as I understand the generic stuff, it is erasured after compiletime anyway - even this worked so fine in guice3 so far.
Kind regards,
avi
edit: found a comment by garvin king that this behavior is in the spec, but not implemented in weld, (staement was in june 2009)
That's rather a long comment than a complete answer to your question, but might point you in the right direction:
I'm following the discussions in seam-dev & weld-dev since quite some time, and do not remember that anything like this ever popped up. So my guess would be that it hasn't been on the agenda ever since Gavin commented about it.
What you can do relatively easy to verify this assumption:
(a) Obtain a reference to the BeanManager and query it for the relevant bean type (or just for Object to be on the save side), of course you will have to remove #Inject in DomainObjectARepositoryTest in order to get the application started.
(b) Register an extension and listen to ProcessBean to what comes up during the deployment. That would be my suggested way to go, you'll find more information here.
With that outcome you should definitely be able to tell if there are any bean types Repository<E, K extends Serializable & Comparable<K>> hanging around :-)
Would be cool if you'd report back here with the results and also considered filing a Jira issue in the negative case.
I've tried to learn the JSF 2.0 by implementing the managed bean via the NetBeans 7. By overview it contains the property as a data object which implements the interface as the following: -
public interface MyInterface1 {
void setName(String name);
String getName();
}
public interface MyInterface2 extends MyInterface1 {
void setPhone(String phone);
String getPhone();
}
public class MyInfo implements MyInterface2 {
//...Getter, Setter
}
#ManagedBean(name="myBean")
public class MyManagedBean {
private MyInfo myInfo = new MyInfo();
//..Getter, Setter
}
When I enter the EL at the JSF/XHTML as
#{myBean.myInfo....}
the methods which are defined at the Super Interface, the MyInterface1 is not displayed.
I'm not sure if it is a tool limitation or I may do something wrong or not.
Could you please help to advise further? Thank you very much for your help in advance. I'm looking forward to hearing from you soon.
Regards,
Charlee Ch.
This is definitely a limitation of the Netbeans editor. I've constantly struggled with similar issues in NB 6.9, code completion would sometimes not work at all, sometimes missing out interfaces/methods, etc. But hey, you can go ahead and type in the method name yourself - it should work.