Foren

retreive date

Sanket Gosavi, geändert vor 12 Jahren.

retreive date

Junior Member Beiträge: 35 Beitrittsdatum: 24.12.11 Neueste Beiträge
i am using <liferay-ui:input-date> to accept date from user...
i want to store date in mysql in Date type column...
i want instruction to get date and store in database.....
thumbnail
Jitendra Rajput, geändert vor 12 Jahren.

RE: retreive date

Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
You can directly store date using services
Sanket Gosavi, geändert vor 12 Jahren.

RE: retreive date

Junior Member Beiträge: 35 Beitrittsdatum: 24.12.11 Neueste Beiträge
But m using Mysql....
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: retreive date

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
So, what's the problem?
It shouldn't matter. Service.xml is independent of database.
Liferay abstracts out which database you're using.

OR are you saying that you're not using service builder and doing a direct jdbc operation on the database table?
Sanket Gosavi, geändert vor 12 Jahren.

RE: retreive date

Junior Member Beiträge: 35 Beitrittsdatum: 24.12.11 Neueste Beiträge
yah...i dnt even knw much about service builder.....m using jdbc connection n entering directly in mysql
database table....m really new to liferay....
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: retreive date

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Have you looked at the following thread? Just do a jdbc in your entity.

http://www.liferay.com/community/forums/-/message_boards/message/11503625
Sanket Gosavi, geändert vor 12 Jahren.

RE: retreive date

Junior Member Beiträge: 35 Beitrittsdatum: 24.12.11 Neueste Beiträge
yah..i hav seen dat post b4.....
this is something m doing.....

<aui:input label="First Name" name="fname"/>
<aui:input label="Last Name" name="lname"/><br>
<aui:select name="Gender">
<aui:option label="Male"></aui:option>
<aui:option label="Female"></aui:option>
</aui:select>

i am able to get inputs from text input and select input using their name attribute...
this is my insert function...

public class ProfilePortlet extends MVCPortlet {

public void insertinfo(ActionRequest actionRequest,ActionResponse actionResponse)throws IOException, PortletException
{
String fname = ParamUtil.getString(actionRequest, "fname");
String gender = ParamUtil.getString(actionRequest, "Gender");


System.out.println("Your inputs ==> " + fname + ", " + gender);


try
{
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost/lportal";
Connection con = (Connection) DriverManager.getConnection(url,"root","sank");
Statement stmt = (Statement) con.createStatement();

String sql1= "insert into lportal.basicc values ('"+ fname +"','"+ lname+"' );";
int cnt = stmt.executeUpdate(sql1);
System.out.println("Done!!"+cnt);
}

catch( Exception e )
{
e.printStackTrace();
}

}


m inserting name and list input succesfully...hav no idea wht to do for date.....

<liferay-ui:input-date formName="dob" yearRangeEnd="2011" yearRangeStart="1950"/>
thumbnail
Mayur Patel, geändert vor 12 Jahren.

RE: retreive date

Expert Beiträge: 358 Beitrittsdatum: 17.11.10 Neueste Beiträge
you can try what hitoshi suggested, get all values in your portlet class, convert those into Date and you can insert into your SQL Query.

//Inside Portlet Class:

                // Getting the Date Range
                    Day = ParamUtil.getInteger(actionRequest, "fromDateDay");
                    Month = ParamUtil.getInteger(actionRequest, "fromDateMonth");
                    Year = ParamUtil.getInteger(actionRequest, "fromDateYear");
 

        // Get Date Range
                    Date = getDate(fromMonth, fromDay, fromYear);
             
        //To get the Actual Date Make a Call to the Method Below:

        public static Date getDate(int month, int day, int year){
               
                Date finalDate = null;
               
                try {
                    finalDate = PortalUtil.getDate(month, day, year, new PortalException());
                } catch (PortalException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    return finalDate = null;
                }
               
                return finalDate;
            }
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: retreive date

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Following page contains some example on setting up aui:datepicker

http://liferayinaction.blogspot.com/2011/10/liferay-taglib-features.html