hi, all
I haved designed one student screen i can able to enter ID and Save it. now before saving the record i want to check that the ID is present or not (duplicate ID) and then i want to save it otherwise throw an error that 'Code already exists.' how to do this? Thanks Vinayak |
it is really important you look through the code to find these answers.
there are many examples. it will also get you familiar with how ofbiz works. Vinayak Yadav sent the following on 10/29/2008 11:11 PM: > hi, all > I haved designed one student screen > i can able to enter ID and Save it. > now before saving the record i want to check that the ID is present or > not (duplicate ID) > and then i want to save it otherwise throw an error that 'Code already exists.' > how to do this? > > Thanks > Vinayak > > |
First, you need an event on request-map (controller) that match your
sent uri After you define a java service. If you know service and controller and if the engine of your service is java you can use this : ***** GenericValue myObject = delegator.findByPrimaryKey("MyObject", UtilMisc.toMap("id", id)); if (UtilValidate.isNotEmpty(myObject)) return ServiceUtil.returnError( "id already exist"); myObject = delegator.makeValidValue("MyObject", context); myObject.create(); ****** It's the greate line ;) Nicolas BJ Freeman a écrit : > it is really important you look through the code to find these answers. > there are many examples. > it will also get you familiar with how ofbiz works. > > Vinayak Yadav sent the following on 10/29/2008 11:11 PM: > >> hi, all >> I haved designed one student screen >> i can able to enter ID and Save it. >> now before saving the record i want to check that the ID is present or >> not (duplicate ID) >> and then i want to save it otherwise throw an error that 'Code already exists.' >> how to do this? >> >> Thanks >> Vinayak >> >> >> > > -- Nicolas MALIN Consultant Tél : 06.17.66.40.06 Site projet : http://www.neogia.org/ ------- Société LibrenBerry Tél : 02.48.02.56.12 Site : http://www.librenberry.net/ |
just to clarify ofbiz does not use objects but entities.
so you should use MyEntity Malin Nicolas sent the following on 10/30/2008 1:20 AM: > First, you need an event on request-map (controller) that match your > sent uri > After you define a java service. > > If you know service and controller and if the engine of your service is > java you can use this : > > ***** > GenericValue myObject = delegator.findByPrimaryKey("MyObject", > UtilMisc.toMap("id", id)); > if (UtilValidate.isNotEmpty(myObject)) return ServiceUtil.returnError( > "id already exist"); > > myObject = delegator.makeValidValue("MyObject", context); > myObject.create(); > ****** > > It's the greate line ;) > > Nicolas > > > BJ Freeman a écrit : >> it is really important you look through the code to find these answers. >> there are many examples. >> it will also get you familiar with how ofbiz works. >> >> Vinayak Yadav sent the following on 10/29/2008 11:11 PM: >> >>> hi, all >>> I haved designed one student screen >>> i can able to enter ID and Save it. >>> now before saving the record i want to check that the ID is present or >>> not (duplicate ID) >>> and then i want to save it otherwise throw an error that 'Code >>> already exists.' >>> how to do this? >>> >>> Thanks >>> Vinayak >>> >>> >>> >> >> > > |
BJ Freeman a écrit :
> just to clarify ofbiz does not use objects but entities. > so you should use MyEntity > You right :), I never use MyObject normaly. > Malin Nicolas sent the following on 10/30/2008 1:20 AM: > >> First, you need an event on request-map (controller) that match your >> sent uri >> After you define a java service. >> >> If you know service and controller and if the engine of your service is >> java you can use this : >> >> ***** >> GenericValue myObject = delegator.findByPrimaryKey("MyObject", >> UtilMisc.toMap("id", id)); >> if (UtilValidate.isNotEmpty(myObject)) return ServiceUtil.returnError( >> "id already exist"); >> >> myObject = delegator.makeValidValue("MyObject", context); >> myObject.create(); >> ****** >> >> It's the greate line ;) >> >> Nicolas >> >> >> BJ Freeman a écrit : >> >>> it is really important you look through the code to find these answers. >>> there are many examples. >>> it will also get you familiar with how ofbiz works. >>> >>> Vinayak Yadav sent the following on 10/29/2008 11:11 PM: >>> >>> >>>> hi, all >>>> I haved designed one student screen >>>> i can able to enter ID and Save it. >>>> now before saving the record i want to check that the ID is present or >>>> not (duplicate ID) >>>> and then i want to save it otherwise throw an error that 'Code >>>> already exists.' >>>> how to do this? >>>> >>>> Thanks >>>> Vinayak >>>> >>>> >>>> >>>> >>> >>> >> > > > -- Nicolas MALIN Consultant Tél : 06.17.66.40.06 Site projet : http://www.neogia.org/ ------- Société LibrenBerry Tél : 02.48.02.56.12 Site : http://www.librenberry.net/ |
In reply to this post by Malin Nicolas
Thanks
I tried following code but i am getting error for 'if statement' please give me a solution. GenericValue myObject = delegator.findByPrimaryKey("HelloTest", UtilMisc.toMap("helloTestId", helloTestId)); if (UtilValidate.isNotEmpty(myObject)) { return ServiceUtil.returnError( "id already exist"); } On Thu, Oct 30, 2008 at 1:50 PM, Malin Nicolas <[hidden email]> wrote: > First, you need an event on request-map (controller) that match your sent > uri > After you define a java service. > > If you know service and controller and if the engine of your service is java > you can use this : > > ***** > GenericValue myObject = delegator.findByPrimaryKey("MyObject", > UtilMisc.toMap("id", id)); > if (UtilValidate.isNotEmpty(myObject)) return ServiceUtil.returnError( "id > already exist"); > > myObject = delegator.makeValidValue("MyObject", context); > myObject.create(); > ****** > > It's the greate line ;) > > Nicolas > > > BJ Freeman a écrit : >> >> it is really important you look through the code to find these answers. >> there are many examples. >> it will also get you familiar with how ofbiz works. >> >> Vinayak Yadav sent the following on 10/29/2008 11:11 PM: >> >>> >>> hi, all >>> I haved designed one student screen >>> i can able to enter ID and Save it. >>> now before saving the record i want to check that the ID is present or >>> not (duplicate ID) >>> and then i want to save it otherwise throw an error that 'Code already >>> exists.' >>> how to do this? >>> >>> Thanks >>> Vinayak >>> >>> >>> >> >> > > > -- > Nicolas MALIN > Consultant > Tél : 06.17.66.40.06 > Site projet : http://www.neogia.org/ > ------- > Société LibrenBerry > Tél : 02.48.02.56.12 > Site : http://www.librenberry.net/ > > |
do you have an entity named HelloTest?
does it have a field helloTestId? Vinayak Yadav sent the following on 10/30/2008 10:06 PM: > Thanks > I tried following code but i am getting error for 'if statement' > please give me a solution. > > GenericValue myObject = delegator.findByPrimaryKey("HelloTest", > UtilMisc.toMap("helloTestId", helloTestId)); > > if (UtilValidate.isNotEmpty(myObject)) > { > return ServiceUtil.returnError( "id already exist"); > } > > On Thu, Oct 30, 2008 at 1:50 PM, Malin Nicolas > <[hidden email]> wrote: >> First, you need an event on request-map (controller) that match your sent >> uri >> After you define a java service. >> >> If you know service and controller and if the engine of your service is java >> you can use this : >> >> ***** >> GenericValue myObject = delegator.findByPrimaryKey("MyObject", >> UtilMisc.toMap("id", id)); >> if (UtilValidate.isNotEmpty(myObject)) return ServiceUtil.returnError( "id >> already exist"); >> >> myObject = delegator.makeValidValue("MyObject", context); >> myObject.create(); >> ****** >> >> It's the greate line ;) >> >> Nicolas >> >> >> BJ Freeman a écrit : >>> it is really important you look through the code to find these answers. >>> there are many examples. >>> it will also get you familiar with how ofbiz works. >>> >>> Vinayak Yadav sent the following on 10/29/2008 11:11 PM: >>> >>>> hi, all >>>> I haved designed one student screen >>>> i can able to enter ID and Save it. >>>> now before saving the record i want to check that the ID is present or >>>> not (duplicate ID) >>>> and then i want to save it otherwise throw an error that 'Code already >>>> exists.' >>>> how to do this? >>>> >>>> Thanks >>>> Vinayak >>>> >>>> >>>> >>> >> >> -- >> Nicolas MALIN >> Consultant >> Tél : 06.17.66.40.06 >> Site projet : http://www.neogia.org/ >> ------- >> Société LibrenBerry >> Tél : 02.48.02.56.12 >> Site : http://www.librenberry.net/ >> >> > > |
yes i have an entity named HelloTest and a field helloTestId
It is giving error for if (UtilValidate.isNotEmpty(myObject)) whether i have to import some libraries for the function 'UtilValidate.isNotEmpty' please advice me Thanks On Fri, Oct 31, 2008 at 10:47 AM, BJ Freeman <[hidden email]> wrote: > do you have an entity named HelloTest? > does it have a field helloTestId? |
what was the error you got in the logs.
Vinayak Yadav sent the following on 10/30/2008 10:22 PM: > yes i have an entity named HelloTest and a field helloTestId > It is giving error for > if (UtilValidate.isNotEmpty(myObject)) > > whether i have to import some libraries for the function > 'UtilValidate.isNotEmpty' > please advice me > > Thanks > > On Fri, Oct 31, 2008 at 10:47 AM, BJ Freeman <[hidden email]> wrote: >> do you have an entity named HelloTest? >> does it have a field helloTestId? > > |
or is this a compile error?
BJ Freeman sent the following on 10/30/2008 10:28 PM: > what was the error you got in the logs. > > Vinayak Yadav sent the following on 10/30/2008 10:22 PM: >> yes i have an entity named HelloTest and a field helloTestId >> It is giving error for >> if (UtilValidate.isNotEmpty(myObject)) >> >> whether i have to import some libraries for the function >> 'UtilValidate.isNotEmpty' >> please advice me >> >> Thanks >> >> On Fri, Oct 31, 2008 at 10:47 AM, BJ Freeman <[hidden email]> wrote: >>> do you have an entity named HelloTest? >>> does it have a field helloTestId? >> > > |
Thanks
The problem has been resolved, i have to include the following library import org.ofbiz.service.ServiceUtil; now how to show or display the error message to the user On Fri, Oct 31, 2008 at 11:02 AM, BJ Freeman <[hidden email]> wrote: > or is this a compile error? > > BJ Freeman sent the following on 10/30/2008 10:28 PM: >> what was the error you got in the logs. |
in the controller that called this, the return would be an error
check the controller.xml for error.jsp. Vinayak Yadav sent the following on 10/30/2008 10:37 PM: > Thanks > The problem has been resolved, i have to include the following library > > import org.ofbiz.service.ServiceUtil; > > now how to show or display the error message to the user > > On Fri, Oct 31, 2008 at 11:02 AM, BJ Freeman <[hidden email]> wrote: >> or is this a compile error? >> >> BJ Freeman sent the following on 10/30/2008 10:28 PM: >>> what was the error you got in the logs. > > |
Thanks
How to display the message box to the user? On Fri, Oct 31, 2008 at 11:17 AM, BJ Freeman <[hidden email]> wrote: > in the controller that called this, the return would be an error > check the controller.xml for error.jsp. > > Vinayak Yadav sent the following on 10/30/2008 10:37 PM: >> Thanks >> The problem has been resolved, i have to include the following library >> >> import org.ofbiz.service.ServiceUtil; >> >> now how to show or display the error message to the user >> >> On Fri, Oct 31, 2008 at 11:02 AM, BJ Freeman <[hidden email]> wrote: >>> or is this a compile error? >>> >>> BJ Freeman sent the following on 10/30/2008 10:28 PM: >>>> what was the error you got in the logs. >> >> > |
In reply to this post by BJ Freeman
unless your using the action section of the widgets.
then you can use the conditions look for <if-compare field-name= BJ Freeman sent the following on 10/30/2008 10:47 PM: > in the controller that called this, the return would be an error > check the controller.xml for error.jsp. > > Vinayak Yadav sent the following on 10/30/2008 10:37 PM: >> Thanks >> The problem has been resolved, i have to include the following library >> >> import org.ofbiz.service.ServiceUtil; >> >> now how to show or display the error message to the user >> >> On Fri, Oct 31, 2008 at 11:02 AM, BJ Freeman <[hidden email]> wrote: >>> or is this a compile error? >>> >>> BJ Freeman sent the following on 10/30/2008 10:28 PM: >>>> what was the error you got in the logs. >> > > |
In reply to this post by Vinayak Yadav
you can only do that in ofbiz, if your using javascript.
other wise you need to use the controller.xml a request-map to call you code and and request-views to display the results. this is covered in the videos, specifically #7 Vinayak Yadav sent the following on 10/30/2008 10:52 PM: > Thanks > > How to display the message box to the user? > > On Fri, Oct 31, 2008 at 11:17 AM, BJ Freeman <[hidden email]> wrote: >> in the controller that called this, the return would be an error >> check the controller.xml for error.jsp. >> >> Vinayak Yadav sent the following on 10/30/2008 10:37 PM: >>> Thanks >>> The problem has been resolved, i have to include the following library >>> >>> import org.ofbiz.service.ServiceUtil; >>> >>> now how to show or display the error message to the user >>> >>> On Fri, Oct 31, 2008 at 11:02 AM, BJ Freeman <[hidden email]> wrote: >>>> or is this a compile error? >>>> >>>> BJ Freeman sent the following on 10/30/2008 10:28 PM: >>>>> what was the error you got in the logs. >>> > > |
Free forum by Nabble | Edit this page |