Change color of Label or Field in SaveAction

Help
2013-06-06
2013-06-21
  • Hi again,
    Im writing an application where, after saving a collection, i connect to a REST service, pass the properties and check if the user needs to fill another field.
    Everything is ok, but i want to signal to the user which fields he should fill (change color of the label, put a image next to the label (similar to the X from the @Required), anything ).
    Im using addInfo, but Im afraid the user will not read all the info.
    Is there a way to do that?
    Thx in advance,
    Fred.

     
  • I think i have to change the property's LabelStyle. Can i do that from an Action? How?

     
  • Javier Paniza
    Javier Paniza
    2013-06-10

    Hi Frederico,

    Is there a way to do that?

    I think that the easiest way it's to define your own CSS for focused element, and then use getView().setFocus() if needed. To define your own CSS add them to the custom.css file in web/xava/style. Look at wiki about this.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • Thanks Javier,
    I Will try that.
    And if i need to highlight more than one field?
    Thx,
    Fred.

     
  • Javier Paniza
    Javier Paniza
    2013-06-12

    Hi Frederico,

    And if i need to highlight more than one field?

    Are these files the required ones?
    Or you want to change the color in a completely arbitrary way from your own logic?


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • Hi, i want to change color arbitrary.

     
  • Javier Paniza
    Javier Paniza
    2013-06-14

    Hi Frederico,

    i want to change color arbitrary

    That is not available currently in OpenXava, maybe we could add this feature in the future. Please, add it as a feature request linking to this thread.

    In the meantime you can achieve to goal executing JavaScript from you OpenXava action, in this way you can change the CSS of the wished fields. Each field has an unique identifier and jquery is available by default in OX.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     
  • Cool. Thanks. I will try that.
    Fred.

     
  • Hi again. Whats the field label? Is there a pattern?

    Now, my action extends SaveElementInCollectionAction and implements IForwardAction.
    My getForwardURI() is returning "javascript:$(\"#label_id\").css(\"color\",\"#f00\");";

    Is this the way to change the label style using jquery?
    Thx in advance,
    Fred.

     
  • Hi. I managed to get this working by changing the css class style. But now i have another problem:
    I enter the action, add some errors (during execute method) and change the style using the getForwardedURI(), but the errors doesnt apear, neither it saves, only the label change. When i click Close, the errors message appear and when i click close again it closes the collection frame.
    Im using OX 4.6.1.
    Is this a bug?

     
  • Javier Paniza
    Javier Paniza
    2013-06-21

    Hi Frederico,

    it is not a bug, if you use forwardURI the application go to another page, so the current one is not update. Given you use forwardURI just to execute javascript this is an inconvenience for you.
    One option can be call from your JavaScript to another OpenXava action that save and add error messages. So you do the work in two steps, one for coloring and another for adding messages and saving.

    If OpenXava supported it by default it would be easier and ellegant, so add the feature request.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.