Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

freemarker.core.InvalidReferenceException

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I tried that now I just get "No value found" in the form.

The updated value is correct everywhere until the



part of UserAction.java

But I can access other u.parameter values in the web page.


The files/methods that I have edited during the extension of the jforum_users table are as follows:

user_form.htm

UserModel.java
- fillUserFromResultSet()
- update()

UserCommon.java
- saveUser()

generic_queries.sql
- UserModel.update

User.java

Have I missed something?

Thanks, appreciate your help.
[originally posted on jforum.net by liam]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, try something like this:



and, in the template, output ${testValue}, and check if the value is correct. If it is, then a call to ${u.getInsAddress1()} should return the same value.

However, please make sure you're not changing the "u" instance after you put it in the context - for exapmle, if you change the "insAddress1" property after adding it to the context, those changes will reflect in the template, because it's the same object instance

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone help - I have been stressing over this for a while.

I have extended the jforum_users table to add a few extra columns, updated the relevant files, web pages etc however I get a freemarker error stating that certain variables are undefined.

I have followed this right back to UserAction.java and know that the value is being inserted and retrieved from the database.

As far as I can see the problem is due to the fact that the variable is not being added to the context - but the user is added correctly



and doing a



returns the correct value prior to adding the user to the context.

My confusion is that some of the new columns in my jforum_users table have been addded whereas others have not but I followed the same process throughout!

Please please help!

Liam
[originally posted on jforum.net by liam]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you accessing them in the template? If



does not work, try



Also, please note that if "propertyName" is null, it will throw an exception ("propertyName not found"). To handle that, you can use ?default, as in



Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I tried ${u.getPropertyName()} and got a undefined error.

The error is



I have traced it back to UserAction edit() method.



if I do a System.out.println(u.getInsAddress1()); before and after the context.put() methods it returns the correct value - however when user_form.htm tries to fill the form with existing data I get the undefined error.

This is happening for several of the new columns but not all of them.

I can't work it out.

Thanks,

Liam
[originally posted on jforum.net by liam]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, try



Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still not working - I'm completely baffled by this.

Did I edit the right files?
[originally posted on jforum.net by liam]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "still not working". What output the suggested approach in my last message did?

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

When I called testValue in the user_form.htm I was given the same error and not output on the form


[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's because the way Freemarker works. Sometimes you have a getter that does point to some property that is not the exact property name.

Most of the time you can use the property, but you can use all available methods as well.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I solved the problem i was having earlier - it was the way I was calling attributes in the entity.

I have one more question though.

Is there a reason why in the htm files we have a mix of method calls and direct access to variables?

For Example:



accesses the variable 'aim' in the User.java entity



and



calls the isAttachSignatureEnabled() method.

Isn't it good practice/security to always use the get methods instead of referencing the attributes themselves?

Thanks,

Liam
[originally posted on jforum.net by liam]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK,

Thanks for all you help with my questions.

Keep up the good work.

Liam
[originally posted on jforum.net by Anonymous]
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic