cancel
Showing results for 
Search instead for 
Did you mean: 

How to fill more values in one field (JSP / HTMLX)

Former Member
0 Kudos

When I want to fill one value in a field on a JSP page, I enter:

value="<%=someClass.getSomeValue() %>"

How should I enter more values (e.g. street, city, postal code, country) in one field?

I tried to put those fields together, so I do one getAddress() call, but the output is (initial screen - supposed to be empty) null null null null

When I enter a customer, the field works ok (no null values).

TIA,

Mylene

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

JSP:

<hbj:inputField

id="CustomerAddressInputField"

type="STRING"

maxlength="10"

value="<%=quotationHeader.getCustomer().getAddress().getAddress() %>"

design="STANDARD"

... %>"

getAddress():

/**

  • @return String (complete address / positioning

  • pCode unsure!)

*/

public final String getAddress()

{

return (street + " " + pCode + " " + city + " " + cCode);

}

-


This is what returns null null null null

What I want (if possible) is to change the getAddress() in the JSP in subsequent getStreet() - add space - getPCode() - add space - getCity() - add space - getCCode()

That will not result in null values - I hope.

But just putting those calls in the string between the

value ="<%= and the %>" tags doesn't seem to work!

TIA,

Mylene

detlev_beutner
Active Contributor
0 Kudos

Hi Mylene,

if the code given above returns "null null null null", the values in fact have been null. Maybe you did not put your "quotationHeader" into the right context (session, page, ...) from where you want to retrieve it within the JSP so that when starting the JSP such an object is created and the member variables are set to null. Or you have put it into the right context, but when doing so, the member variables have been null.

So the code given should work perfectly when the address fields have been set to real values and when the JSP uses the same object (instance) which you have set before.

There should be no reason to change the code so that you build the concatenated within the JSP. Looks ugly ("<%= quotationHeader.getCustomer().getAddress().getStreet() + " " + quotationHeader.getCustomer().getAddress().getPCode() + " " + ... %>").

Nevertheless, it should work. You write that it "doesn't seem to work" - what does that mean? Any exception?

Hope it helps

Detlev

PS: Would be better if you mark your question as question. With this, you can also award points for helping answers (the yellow star).

Former Member
0 Kudos

Looks ugly ("<%= quotationHeader.getCustomer().getAddress().getStreet() + " " + quotationHeader.getCustomer().getAddress().getPCode() + " " + ... %>").

Jup, it looks ugly - and returns nullnullnullnull (I had to remove the " " parts - the program crashed)

And AFAIK I made the first post a question

Thanks a lot....

Mylene

detlev_beutner
Active Contributor
0 Kudos

Hi Mylene,

for the "+ " " " part, I didn't test it, at least than it should work with " new String(" ") +", which does not make the code looking better

But sure, if your short code with "getAdress().getAdress()" returns null..., the UCV (UglyCodeVersion ) will return these null values, too.

So I hope you can detect where these null values come from.

And - the whole forum software sometimes works strange...

Hope it helps

Detlev

detlev_beutner
Active Contributor
0 Kudos

Hi Mylene,

to clarify to your question, could you post the code you tried which does nt work for you? At least for me the question is not clear (if null is printed, it will have bean null, sounds like you did not initialize your object correctly?!).

Hope I can help after clarification

Detlev