Combination View Flat View Tree View
Threads [ Previous | Next ]
Alf Høgemark
Liferay UI taglib : suggestions for input-field tag
September 7, 2008 10:44 AM
Answer

Alf Høgemark

Rank: Junior Member

Posts: 34

Join Date: May 24, 2008

Recent Posts

Hi

I have been using the input-field tag in the UI part of the Liferay tag library.

Here are my suggestions to improving the tag, and also some questions as how it is working :

1.
The tag should support datatypes Integer and Double. Currently it supports int and double, but I would like to have support for the non primitive numeric types as well.
Why ? Because I want to be able to support numeric properties that does not have to have a value.

Currently, if i have a int property, the input-field tag will display "0" when the property has no value.
How do people use numeric properties in ServiceBuilder and using the input-field tag ?
Do you use "int" or "Integer" as the type ?

2.
The "fieldParam" property of the input-field does not seem to be working correctly. I assume this property is used to specify what the "fieldname" should be in the HTML generated. If you specify a fieldParam and the type is either String, int or double, the default value will always be displayed. There seems to be a bug in the tag.
To me, it seems like the code should be changed similar to this :
Index: portal-web/docroot/html/taglib/ui/input_field/page.jsp
===================================================================
--- portal-web/docroot/html/taglib/ui/input_field/page.jsp (revision 20078)
+++ portal-web/docroot/html/taglib/ui/input_field/page.jsp (working copy)
@@ -198,6 +198,10 @@

if (fieldParam == null) {
fieldParam = namespace + field;
+ }
+ else {
+ fieldParam = namespace + fieldParam;
+ }

if (type.equals("double")) {
value = String.valueOf(BeanParamUtil.getDouble(bean, request, field, GetterUtil.getDouble(defaultString)));
@@ -214,11 +218,6 @@
value = httpValue;
}
}
- }
- else {
- fieldParam = namespace + fieldParam;
- value = defaultString;
- }

boolean autoEscape = true;

If there is no comments to this, I will raise an issue as support.liferay.com for this.

3.
When the input-field is set up to display an numeric attribute, there does not seem to be any validation of input anywhere. I was expecting the framework to make sure the user only entered a valid numeric value, or displayed an error message if not.
Is there support for validating the input for numeric properties ?

4.
I also think that the "readonly" attribute on standard HTML input tag should be supported by the UI input-field tag.


Regards
Alf Hogemark
Alf Høgemark
RE: Liferay UI taglib : suggestions for input-field tag
September 10, 2008 12:22 PM
Answer

Alf Høgemark

Rank: Junior Member

Posts: 34

Join Date: May 24, 2008

Recent Posts

Hi

I just realized that since I'm writing Struts Portlets, I should rather use the struts html tags, instead of the Liferay tag library.
The struts tags have all the functionality I need, and I also think it makes the jsp page code look cleaner and nicer.

Regards
Alf Hogemark
zahra karami
RE: Liferay UI taglib : suggestions for input-field tag
April 8, 2009 1:54 AM
Answer

zahra karami

Rank: New Member

Posts: 3

Join Date: March 10, 2009

Recent Posts

Hello Alf
first pardon me for my little english

to add custom validation on input tag in liferay (<liferay-ui:input-field ) ,
you can use of java Script codes , and on submit form you call your java Script function
for example if you want only nummeric format field , use this code :

==============================
in a jsp page in webapps\ROOT\html\portlet\login\
==============================
<script language="javascript">
function isNumeric (text)
{
var ch;
var Numbers = "1234567890";
for (var i=0;i<text.length;i++)
{
ch = Numbers.indexOf(text.charAt(i))
if (ch == -1)
return false;
}
return true;
}
----------------------------------------------------------------------------------------
function checkForm()
{
var MyNumber = document.form.MyFeild;
if(!isNumeric(MyNumber .value) )
{
alert(" Your input is not a number");
return false;
}
return true;
}
</script>
-----------------------------------------------------------------------------------
<form onSubmit="return checkForm();" action="<portlet:actionURL windowState="<%= WindowState.MAXIMIZED.toString() %>" name="form1">

<liferay-ui:input-field model="<%= Contact.class %>" bean="<%= contact2 %>" field="middleName" name="MyFeild" />
------------------------------------------------------------------------------------
I hope this code help you and solve part of your problem
-----------------------------------------------------------------------------------
I use this code but Icould not get the name of the input field . can any body help me?
vikas suresh thakre
How to make liferay-ui:input-field readonly ?
February 21, 2010 10:16 PM
Answer

vikas suresh thakre

Rank: Junior Member

Posts: 97

Join Date: May 18, 2009

Recent Posts

Hi All,

is it possible to make <liferay-ui:input-field /> this field readonly.

i get disabled from the tld, it's also solved my purpose but when i try to save that page it can't able to read the text field. For example i had made screen name disabled in the user profile information page and then try to save that page, it is giving me the validation error that "Please enter a valid screen name."

any help here is really appreciable

thanks
Vikas Thakre.
Cesar Gutierrez
RE: How to make liferay-ui:input-field readonly ?
August 18, 2010 7:48 AM
Answer

Cesar Gutierrez

Rank: New Member

Posts: 5

Join Date: August 17, 2010

Recent Posts

vikas suresh thakre:
Hi All,

is it possible to make <liferay-ui:input-field /> this field readonly.

i get disabled from the tld, it's also solved my purpose but when i try to save that page it can't able to read the text field. For example i had made screen name disabled in the user profile information page and then try to save that page, it is giving me the validation error that "Please enter a valid screen name."

any help here is really appreciable

thanks
Vikas Thakre.


i have the same problem, u fix it? or anyone else?, thx.
Cesar Gutierrez
RE: How to make liferay-ui:input-field readonly ?
August 18, 2010 8:07 AM
Answer

Cesar Gutierrez

Rank: New Member

Posts: 5

Join Date: August 17, 2010

Recent Posts

well searching in liferay forum i got the solution xD, adding a hidden input field solve my problem

1<liferay-ui:input-field model="<%= User.class %>" bean="<%= selUser %>" field="screenName" disabled="<%= true %>"/>
2[b]<input name="<portlet:namespace />screenName" type="hidden" value= <%=selUser.getScreenName() %>" />[/b]
Reinaldo Silva
RE: Liferay UI taglib : suggestions for input-field tag
October 5, 2010 9:15 PM
Answer

Reinaldo Silva

Rank: New Member

Posts: 3

Join Date: December 2, 2009

Recent Posts

For <aui:input> Date type fields:

* Allow render without a predefined date to avoid lazy users for critical input.
* Once set, also allow blank / nullify dates for null/non-required date fields.
Mohammed Azam
RE: Liferay UI taglib : suggestions for input-field tag
October 18, 2010 11:42 PM
Answer

Mohammed Azam

Rank: Regular Member

Posts: 159

Join Date: November 6, 2009

Recent Posts

Hi,

I used your piece of code in order to understand how to get the value of the inputfield in javascript.
here is the solution--
 1function checkForm(){
 2        var MyNumber = document.getElementById('<portlet:namespace/>middleName');
 3
 4        if(!isNumeric(MyNumber .value) )
 5        {
 6            alert(" please enter a valid phone number");
 7            return false;
 8        }
 9        return true;
10    }

this will serve your purpose.
Ming Wu
RE: How to make liferay-ui:input-field readonly ?
July 17, 2012 8:54 PM
Answer

Ming Wu

Rank: New Member

Posts: 1

Join Date: June 17, 2012

Recent Posts

<aui:input name="xxx" label="xxx" readonly="readonly"></aui:input>
Massimiliano Assante
RE: How to make liferay-ui:input-field readonly ?
January 15, 2013 7:28 AM
Answer

Massimiliano Assante

Rank: Junior Member

Posts: 49

Join Date: March 4, 2010

Recent Posts

Ming Wu:
<aui:input name="xxx" label="xxx" readonly="readonly"></aui:input>


this does not work (liferay 6.0.6 CE)
Umer Sayeed
RE: How to make liferay-ui:input-field readonly ?
March 7, 2013 2:30 AM
Answer

Umer Sayeed

Rank: Junior Member

Posts: 51

Join Date: August 8, 2012

Recent Posts

$(document).ready(function(){
document.getElementById('name').readOnly=true
});

<tr><td>Name<b style="color: red;">*</b></td><td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td> <aui:input label="" name="name" /></td></tr>
Jorge García
RE: How to make liferay-ui:input-field readonly ?
August 7, 2013 1:10 AM
Answer

Jorge García

Rank: New Member

Posts: 10

Join Date: May 11, 2012

Recent Posts

Have you tried the disabled property?

<liferay:ui-input name="name" label="label" disabled="true"/>