Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:51:19+00:00 2026-06-14T12:51:19+00:00

I try to bind a bean to a form snippet from the form: [#ftl/]

  • 0

I try to bind a bean to a form snippet from the form:

[#ftl/]
[#import "spring.ftl" as spring /]
[#import "panda.ftl" as panda /]

[#import "discoveryProject.ftl" as discoveryProject/]
[#macro defineProjectForm newProject]
[@spring.bind "discoveryProjectDetailsBean"/]

[#if newProject?has_content && newProject =="true"]
<table class="transparentTable">
    <tr>
        <!--Left Part-->
        <td>
            <table>
                <tr>
                    <td>
                        [@spring.showErrors " " "errors"/]
                        <span>Data Source<sup><span style="color: red; ">*</span></sup></span>
                    </td>
                    <td>
                        <select id="dataSourceSelect" onchange="checkSelectChanges()">
                            [#if discoveryProjectLookupBean.dataSources?has_content]
                                [#list discoveryProjectLookupBean.dataSources as dataSource]
                                    <option id="${dataSource.id}" value="${dataSource.name}">${dataSource.name}</option>
                                [/#list]
                            [/#if]
                        </select>
                    [@spring.bind path="discoveryProjectDetailsBean.discoveryProjectBean.dataSource"/]
                    </td>
                </tr>
            </table>

this is submitted to a controller, snippet to this controller:

@RequestMapping("/navigateDiscoveryProject")
ModelAndView navigateDiscoveryProject(@RequestParam("index")String i,@RequestParam("direction")String direction,
        @ModelAttribute("discoveryProjectDetailsBean")DiscoveryProjectDetailsBean discoveryProjectDetailsBean,BindingResult result,HttpSession session)throws Exception{
    logger.info("method invoked");
    int index=Integer.parseInt(i);
    //another code
}

the bean discoveryProjectDetailsBean contains property which is actually another bean discoveryProjectBean this bean’s properties are always null however I bind them myself in the ftl like in the dataSource property example above, all the values of properties to the discoveryProjectBean are always null.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:51:20+00:00Added an answer on June 14, 2026 at 12:51 pm

    I have found two answers for my problem.
    the first way is to bind each property alone, see I was only binding the command object while I should’ve binded each property to its specific controller.
    like this

    [#ftl/]
    [#import "spring.ftl" as spring /]
    [#import "panda.ftl" as panda /]
    
    [#import "discoveryProject.ftl" as discoveryProject/]
    [#macro defineProjectForm newProject]
    // this is useless [@spring.bind "discoveryProjectDetailsBean"/]
    
    [#if newProject?has_content && newProject =="true"]
    <table class="transparentTable">
        <tr>
            <!--Left Part-->
            <td>
                <table>
                    <tr>
                        <td>
                            [@spring.showErrors " " "errors"/]
                            <span>Data Source<sup><span style="color: red; ">*</span></sup></span>
                        </td>
                        <td>
                            <select id="discoveryProjectBean.dataSource" name="discoveryProjectBean.dataSource" onchange="checkSelectChanges()">
                                [#if discoveryProjectLookupBean.dataSources?has_content]
                                    [#list discoveryProjectLookupBean.dataSources as dataSource]
                                        <option id="${dataSource.id}" value="${dataSource.name}">${dataSource.name}</option>
                                    [/#list]
                                [/#if]
                            </select>
    //the following binding work just fine
                            [@spring.bind path="discoveryProjectDetailsBean.discoveryProjectBean.dataSource"/]
                        </td>
                    </tr>
                </table>
    

    what I did above is that I get the property I need from the command object set it as the name and ID of the select tag and binded the tag to the property using @spring.bind.

    this is the best solution

    an alternative is to do it like this:

    [#ftl/]
    [#import "spring.ftl" as spring /]
    [#import "panda.ftl" as panda /]
    
    [#import "discoveryProject.ftl" as discoveryProject/]
    [#macro defineProjectForm newProject]
    [@spring.bind "discoveryProjectDetailsBean"/]
    
    [#if newProject?has_content && newProject =="true"]
    <table class="transparentTable">
        <tr>
            <!--Left Part-->
            <td>
                <table>
                    <tr>
                        <td>
                            [@spring.showErrors " " "errors"/]
                            <span>Data Source<sup><span style="color: red; ">*</span></sup></span>
                        </td>
                        <td>
                            [@spring.bind "dataSources"/]
                    [@spring.formSingleSelect "discoveryProjectDetailsBean.discoveryProjectBean.dataSource" dataSources "disabled='disabled' multiple='multiple' class='singleList' onchange='checkValidations()'" /]
    
                        </td>
                    </tr>
                </table>
    

    no this provide less coding but gives limitations with the list of options in your select tag, see you get a list of string to bind it to the @spring.formSingleSelect this is the dataSources in the code above if this list is anything but list of string it will generate a freemarker exception of freemarker.template.TemplateException:.
    I hope this would help somebody

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to bind a valueconverter from a defined enum Status to brush,
I try to bind value from input select to attribute selectedValue in controller. This
I try to bind a array from another array's change. but it not work.
I try to bind an IPv6 server socket in Java 1.6 on Windows 7,
I am try to bind the dropdowmlist using jquery. But is showing some error.
I'm trying to bind a function with a non-existent class. I will try to
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
When I try to bind overloaded property in PDOStatement::bindParam method, $stmt->bindParam(':'.$field.'', $this->$field, $pdoparam); ...
I have some problems when I try to bind the height and width of
I am new to c# and try to bind a datagridview to a mssql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.