Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to pass input field values in to java ?

Avatar

Avatar
Level 1
aemcrook
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
aemcrook
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
aemcrook
Level 1

04-09-2018

I have designed one page using HTL . my page components contains one input text field and button. how  i can pass my text field values in to java class.

Here is my HTL code .

<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html" data-sly-call="${clientlib.all @ categories='s7.s7dataset.style'}"/>

<div data-sly-use.s7dataset="com.dam.service.Info">

<header id="header" class="hoc clear">

<form class="search foundation-form granite-omnisearch-form">

<input class="searchTerm" placeholder="search scene7 ..." /> <input

class="searchButton" type="submit" />

</form>

</header>

Here is my java code:

-------------------

package  com.dam.service

public class Info extends WCMUsePojo {

  @Override

    public void activate() throws Exception {

    

  }

}

I am not sure that can i use WCMUsePojo or not . anybody help me to get value in to java .?

Replies

Avatar

Avatar
Give Back 5
Level 2
k_ra
Level 2

Likes

4 likes

Total Posts

25 posts

Correct Reply

1 solution
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 3
View profile

Avatar
Give Back 5
Level 2
k_ra
Level 2

Likes

4 likes

Total Posts

25 posts

Correct Reply

1 solution
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 3
View profile
k_ra
Level 2

05-09-2018

You can set the form method to "GET" and use this getRequest().getParameter("id") to get the values from the input fields.

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

05-09-2018

HI,

You can pass value from HTL to java like below:

HTL

<div data-sly-use.cf="${'com.aem.community.core.components.ContentFragmentContent' @ cfInput=properties.cfdata, variation=properties.variation},cfMode='some mode'">

Java

public void activate() {

  String cfInput = get("cfInput", String.class);

String cfVariation = get("cfVar", String.class);

String mode = get("cfMode", String.class);

But In your case you can't pass value from client side to Java Use API.

But value can be pass when form is submitted and value can be fetched at action page/servlet/jsp etc.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

05-09-2018

When using HTL - to get values to Java, you can either use:

1 - a component dialog - Creating an Adobe Experience Manager 6.4 HTL component that uses the WCMUsePojo API

2 - or use a HTTP POST or GET operation - this would be sent to a servlet however.

In your form use case - you can use AJAX to sent the values to a Java Servlet - you cannot pass that to WCMUSEPojo as that happens when the dialog is filled out.