• 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
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

how to add extra columns into existing table?

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying very very hard to custom jforum to implement a forum for my own community. One of those works is to insert a new column into 'jforum_users' table for an extra user property, say, 'gender'. (I know there is a 'gender' column in this table, just for example)

Here is what I've done:


1.Update User.java to identify the new table structure



2.Update 'fillUserFromResultSet' and 'update' methods in GenericUserDAO.java,

3.rewrite statements in *.sql file

4.I changed the user_form.htm and add the following code

5.Of cause I changed en_US.properties...


I thought it would work out. Ooops! When editting personal information through the 'user_form.htm' I got the following exception:


if u.getGender() [on line 119, column 79 in default/user_form.htm] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression isGenderMale is undefined on line 119, column 84 in default/user_form.htm. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134) at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:114) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.isTrue(Expression.java:138) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.Environment.process(Environment.java:176) at freemarker.template.Template.process(Template.java:232) at net.jforum.JForum.processCommand(JForum.java:236) at net.jforum.JForum.service(JForum.java:203) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) at java.lang.Thread.run(Thread.java:595)



I've read the document for freemarker. However the deeper i dig, the more confused I am! Freemarker seems to fetch information from the data model of jforum. I tracked the 'context' hash map, and found the u.gender was right there with correct value, so I changed the code in user_form.htm into

The exception was still there telling that u.gender is undefined! Now I am somewhat depressed!What the entity of jforum data model, and how can I get access to it at all?

I am quite a rookie on programming, still growing though. With respect and the feeling of being exhausted I hope guys in this community can help me out. Thanks.
[originally posted on jforum.net by workinghard]
 
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
I just made one more experiment. It seems to work.



in the user_form.htm are <#if u.isGenderMale() and isGenderFemale correspondingly. Seems that '<#if' expression only recognize boolean value... am i right?
[originally posted on jforum.net by workinghard]
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic