You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by cablepuff <ca...@gmail.com> on 2011/04/19 06:59:07 UTC

org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: userName;

Hi I have the following domain object

public class User {
   private String email;
   private String firstName;
   private String lastName;
   private Account account;
   
   public String getUserName() {
          return this.account.getName();
   }

   public void setUserName(String username) {
        this.account.setName(username); 
  }
}

I have a form with dropdownchoice.

final DropDownChoice<User> userChoice = new
DropDownChoice<Person>("userChoice",
                                               new ListModel<User>(users),
new ChoiceRenderer<User>("userName", "userName"));

When the page loads i get this error!

org.apache.wicket.WicketRuntimeException: No get method defined for class:
class java.lang.String expression: userName
	at
org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:492)
	at
org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:332)
	at
org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:242)
	at
org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:95)
	at
org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:145)
	at
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:166)
	at
org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:879)
	at
org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:353)
	at org.apache.wicket.Component.renderComponent(Component.java:2690)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
	at org.apache.wicket.Component.render(Component.java:2521)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
	at
org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
	at
org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1528)
	at
org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:2012)
	at org.apache.wicket.Component.renderComponent(Component.java:2690)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
	at org.apache.wicket.Component.render(Component.java:2521)
	at
org.apache.wicket.markup.html.border.Border$BorderBodyContainer.resolve(Border.java:421)
	at
org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:65)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1445)
	at
org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
	at
org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1528)
	at
org.apache.wicket.markup.html.border.Border$BorderBodyContainer.onComponentTagBody(Border.java:403)
	at org.apache.wicket.Component.renderComponent(Component.java:2690)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
	at org.apache.wicket.Component.render(Component.java:2521)
	at org.apache.wicket.markup.html.border.Border.resolve(Border.java:287)
	at
org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:65)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1445)
	at
org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
	at
org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1528)
	at
org.apache.wicket.markup.html.border.Border$BorderBodyContainer.onComponentTagBody(Border.java:403)
	at org.apache.wicket.Component.renderComponent(Component.java:2690)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
	at org.apache.wicket.Component.render(Component.java:2521)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
	at
org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
	at
org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:697)
	at
org.apache.wicket.markup.html.border.Border.onComponentTagBody(Border.java:328)
	at org.apache.wicket.Component.renderComponent(Component.java:2690)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
	at org.apache.wicket.Component.render(Component.java:2521)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
	at
org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
	at
org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:697)
	at
org.apache.wicket.markup.html.border.Border.onComponentTagBody(Border.java:328)
	at org.apache.wicket.Component.renderComponent(Component.java:2690)
	at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
	at org.apache.wicket.Component.render(Component.java:2521)
	at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
	at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1555)
	at org.apache.wicket.Page.onRender(Page.java:1594)
	at org.apache.wicket.Component.render(Component.java:2521)
	at org.apache.wicket.Page.renderPage(Page.java:932)
	at
org.apache.wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:201)
	at
org.apache.wicket.request.target.coding.HybridUrlCodingStrategy$HybridBookmarkablePageRequestTarget.respond(HybridUrlCodingStrategy.java:983)
	at
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)
	at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258)
	at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
	at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
	at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
	at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
	at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:223)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:576)
	at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at
org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:333)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)

What is wrong? 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-WicketRuntimeException-No-get-method-defined-for-class-class-java-lang-String-expr-tp3459462p3459462.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: userName;

Posted by cablepuff <ca...@gmail.com>.
Hi Martin, yesterday that was the domain (persistent object was called User). 

The command object was call Account hence AccountCommand.

Anyways I solve my problem by adding a additional parameter. 

new DropDownChoice<Person>("userChoice", new
CompoundPropertyModel(selectedUser),
                                               new ListModel<User>(users),
new ChoiceRenderer<User>("userName", "userName")); 

This solve the problem. 

Thanks. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-WicketRuntimeException-No-get-method-defined-for-class-class-java-lang-String-expr-tp3459462p3465163.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: userName;

Posted by Martin Grigorov <mg...@apache.org>.
Yesterday you pasted code with class User which is nowhere in the today's
paste.
We are not oracles. We cannot help you if you give us wrong information.

On Wed, Apr 20, 2011 at 4:28 PM, cablepuff <ca...@gmail.com> wrote:

> final LoadableDetachableModel<AccountCommand> accountCommand = new
> AccountDetachableModel(userId, personId);
>
>
> final AccountForm form = new AccountForm("accountForm", accountCommand);
>
>
> My AccountCommand {
>  private Integer userId;
>    private Integer accountId;
>    private String  accountName;
>    private String  accountFN;
>    private String  accountLN;
> }
>
>  it does not have userName field since the userName getters is on the User
> domain object not Account command object.
>
> My AccountDetachableModel is just
>
> @Override
> protected AccountCommand load() {
>    AccountCommand accountCommand = new AccountCommand();
>    // query id and set the account command field.
>    return accountCommand;
> }
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-WicketRuntimeException-No-get-method-defined-for-class-class-java-lang-String-expr-tp3459462p3462988.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: userName;

Posted by cablepuff <ca...@gmail.com>.
final LoadableDetachableModel<AccountCommand> accountCommand = new
AccountDetachableModel(userId, personId);


final AccountForm form = new AccountForm("accountForm", accountCommand);


My AccountCommand {
 private Integer userId;
    private Integer accountId;
    private String  accountName;
    private String  accountFN;
    private String  accountLN;
}

 it does not have userName field since the userName getters is on the User
domain object not Account command object. 

My AccountDetachableModel is just 

@Override
protected AccountCommand load() {
    AccountCommand accountCommand = new AccountCommand();  
    // query id and set the account command field. 
    return accountCommand;
}

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-WicketRuntimeException-No-get-method-defined-for-class-class-java-lang-String-expr-tp3459462p3462988.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: userName;

Posted by Clint Checketts <ch...@gmail.com>.
The error is in the model you gave your form. Since you aren't explicitly
stating a model for the DDC, it is assuming a CompoundPropertyModel on the
parent form.

I suspect your form declaration is something like

 new Form("form",new CompoundPropertyModel(getUserName()))

It should be something like

 new Form("form",new CompoundPropertyModel(new User()))

I'm personally not a fan of CPMs and prefer explicitly setting the model for
each of my components.

-Clint

On Mon, Apr 18, 2011 at 11:59 PM, cablepuff <ca...@gmail.com> wrote:

> Hi I have the following domain object
>
> public class User {
>   private String email;
>   private String firstName;
>   private String lastName;
>   private Account account;
>
>   public String getUserName() {
>          return this.account.getName();
>   }
>
>   public void setUserName(String username) {
>        this.account.setName(username);
>  }
> }
>
> I have a form with dropdownchoice.
>
> final DropDownChoice<User> userChoice = new
> DropDownChoice<Person>("userChoice",
>                                               new ListModel<User>(users),
> new ChoiceRenderer<User>("userName", "userName"));
>
> When the page loads i get this error!
>
> org.apache.wicket.WicketRuntimeException: No get method defined for class:
> class java.lang.String expression: userName
>        at
>
> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:492)
>        at
>
> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:332)
>        at
>
> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:242)
>        at
>
> org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:95)
>        at
>
> org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:145)
>        at
>
> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:166)
>        at
>
> org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:879)
>        at
>
> org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:353)
>        at org.apache.wicket.Component.renderComponent(Component.java:2690)
>        at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
>        at
>
> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
>        at
>
> org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1528)
>        at
> org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:2012)
>        at org.apache.wicket.Component.renderComponent(Component.java:2690)
>        at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at
>
> org.apache.wicket.markup.html.border.Border$BorderBodyContainer.resolve(Border.java:421)
>        at
>
> org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:65)
>        at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1445)
>        at
>
> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
>        at
>
> org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1528)
>        at
>
> org.apache.wicket.markup.html.border.Border$BorderBodyContainer.onComponentTagBody(Border.java:403)
>        at org.apache.wicket.Component.renderComponent(Component.java:2690)
>        at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at
> org.apache.wicket.markup.html.border.Border.resolve(Border.java:287)
>        at
>
> org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:65)
>        at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1445)
>        at
>
> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
>        at
>
> org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1528)
>        at
>
> org.apache.wicket.markup.html.border.Border$BorderBodyContainer.onComponentTagBody(Border.java:403)
>        at org.apache.wicket.Component.renderComponent(Component.java:2690)
>        at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
>        at
>
> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
>        at
>
> org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:697)
>        at
>
> org.apache.wicket.markup.html.border.Border.onComponentTagBody(Border.java:328)
>        at org.apache.wicket.Component.renderComponent(Component.java:2690)
>        at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
>        at
>
> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1604)
>        at
>
> org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:697)
>        at
>
> org.apache.wicket.markup.html.border.Border.onComponentTagBody(Border.java:328)
>        at org.apache.wicket.Component.renderComponent(Component.java:2690)
>        at
> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1539)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at
> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1441)
>        at
> org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1555)
>        at org.apache.wicket.Page.onRender(Page.java:1594)
>        at org.apache.wicket.Component.render(Component.java:2521)
>        at org.apache.wicket.Page.renderPage(Page.java:932)
>        at
>
> org.apache.wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:201)
>        at
>
> org.apache.wicket.request.target.coding.HybridUrlCodingStrategy$HybridBookmarkablePageRequestTarget.respond(HybridUrlCodingStrategy.java:983)
>        at
>
> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)
>        at
>
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258)
>        at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
>        at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
>        at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
>        at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
>        at
>
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
>        at
>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>        at
>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>        at
>
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
>        at
>
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>        at
>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>        at
>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>        at
>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:223)
>        at
>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
>        at
>
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:576)
>        at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
>        at
>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
>        at
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
>        at
>
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>        at
>
> org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:333)
>        at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
>        at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
>        at
>
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
>        at
>
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
>        at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:619)
>
> What is wrong?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/org-apache-wicket-WicketRuntimeException-No-get-method-defined-for-class-class-java-lang-String-expr-tp3459462p3459462.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>