#Product Management Problem

62 messages ยท Page 1 of 1 (latest)

magic zenith
#

I am in the process of modifying a JavaFX program that allows me to use Splash app and integrate unit of measure. It is a product management software with a list view that showcases what you created, deleted, and modified. Somehow, despite having outfitted every code without error, creating a product for the list just ends up as null and the Combobox used for the units has nonexistent values. Anyone interested in helping me crack this code?

brisk brookBOT
#

โŒ› This post has been reserved for your question.

Hey @magic zenith! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

magic zenith
#

Here is the error in question

severe badger
magic zenith
#

A bit of a warning, this program here needs a filepath to Java and Maven folders from your File Explorer

not only that, an SQL Configurator needs to be set up in order to use your own password in its yml file

magic zenith
#

Unless you don't wanna run it, I could just send the file immediately?

severe badger
magic zenith
#

Hold on

scarlet cipherBOT
#

package com.gabriel.prodmsv;

import com.gabriel.prodmsv.ServiceImpl.ProductService;
import com.gabriel.prodmsv.model.Product;
import com.gabriel.prodmsv.model.Uom;
import com.gabriel.prodmsv.ServiceImpl.UomService;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.stage.Window;
import lombok.Setter;

import java.net.URL;
import java.util.ResourceBundle;

@Setter ```java

public class CreateProductController implements Initializable {
@Setter
ProdManController prodManController;
@FXML
public TextField tfName;
@FXML
public TextField tfDesc;
@FXML
private ComboBox<Uom> cbUom;
public Button btnSubmit;
public Button btnNext;

@Setter
Stage stage;
@Setter
Scene parentScene;
@Setter
ProductService productService;
@Setter
UomService  uomService;

@Override
public void initialize(URL url, ResourceBundle resourceBundle){
    System.out.println("CreateProductController: initialize");

    try{
    Uom[] uoms = UomService.getService().getUoms();
    cbUom.getItems().clear();;
    cbUom.getItems().addAll(uoms);

    tfName.setText("");
    tfDesc.setText("");
    } catch(Exception e){
        System.out.println(e.getMessage());
    }
}

public void clearControlTexts(){
    tfName.setText("");
    tfDesc.setText("");
    cbUom.getSelectionModel().clearSelection();
} ```

This message has been formatted automatically. You can disable this using /preferences.

#
public void onNext(ActionEvent actionEvent) {
        System.out.println("CreateProductController:onBack ");
        Node node = ((Node) (actionEvent.getSource()));
        Window window = node.getScene().getWindow();
        window.hide();

        stage.setScene(parentScene);
        stage.show();
    }

    public void onSubmit(ActionEvent actionEvent) throws Exception{
        Product product = new Product();
        product.setName(tfName.getText());
        product.setDescription(tfDesc.getText());
        Uom uom = cbUom.getSelectionModel().getSelectedItem();
        product.setUomId(uom.getId());
        product.setUomName(uom.getName());
        try{
            // Ensure productService is not null
            if(productService == null){
                productService = ProductService.getService();
            }
            prodManController.refresh();
            onBack(actionEvent);
        } catch(Exception ex){
            System.out.println("CreateProductController:onSubmit Error: " + ex.getMessage());
        }
    }

    public void onBack(ActionEvent actionEvent) {
        System.out.println("CreateProductController:onBack ");
        Node node = ((Node) (actionEvent.getSource()));
        Window window = node.getScene().getWindow();
        window.hide();

        stage.setScene(parentScene);
        stage.show();
    }
} ```

This message has been formatted automatically. You can disable this using /preferences.

magic zenith
#

So far, most of the codes have a usage

#

I checked back on the directory leading to the codes for the Unit of measure

severe badger
magic zenith
scarlet cipherBOT
#

package com.gabriel.prodmsapp.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.Date;

@Data
@Entity
@Table(name = "uom_data") ```java

public class UomData {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
int id;
String name;

@UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
private Date lastUpdated;

@CreationTimestamp
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
private Date created;

} ```

This message has been formatted automatically. You can disable this using /preferences.

severe badger
#

But this are two different issues. First issue is how to populate combobox with items and second how to retrieve them.

#

When you open the cmb can you see some items or not?

magic zenith
severe badger
#

well, than first you have to check whether you are loading your items correctly

#

check if there are some items returned from call "UomService.getService().getUoms()"

severe badger
#

well, than you have to figure out why

magic zenith
severe badger
#

show me how you retrieve Uoms...

magic zenith
#

can't i just send the file?
it'd be convenient if we both see through it
with your permission, of course

severe badger
#

just post it here. It should be few pieces of lines of code

scarlet cipherBOT
#
public Uom create(Uom uom) {
        String url = endpointUrl;
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<Uom> request = new HttpEntity<>(uom, headers);
        final ResponseEntity<Uom> response =
                getRestTemplate().exchange(url, HttpMethod.PUT, request, Uom.class);
        return response.getBody();
    }

public Uom update(Uom uom) {
        logger.info("update: " + uom.toString());
        String url = endpointUrl;
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<Uom> request = new HttpEntity<>(uom, headers);
        final ResponseEntity<Uom> response =
                getRestTemplate().exchange(url, HttpMethod.POST, request, Uom.class);
        return response.getBody();
    }

public void delete(Integer id) {
        logger.info("delete: " + Integer.toString(id));
        String url = endpointUrl + "/" + Integer.toString(id);
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<Uom> request = new HttpEntity<>(null, headers);
        final ResponseEntity<Uom> response =
                getRestTemplate().exchange(url, HttpMethod.DELETE, request, Uom.class);
    } ```

This message has been formatted automatically. You can disable this using /preferences.

severe badger
#

okay, this is create, update and delete. What about get?

scarlet cipherBOT
#
public static UomService getService(){
        if(service == null){
            service=new UomService();
        }
        return service;
    }
    public RestTemplate getRestTemplate() {
        if (restTemplate == null) {
            restTemplate = new RestTemplate();
            List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
            MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
            converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
            messageConverters.add(converter);
            restTemplate.setMessageConverters(messageConverters);
        }
        return restTemplate;
    }

    public Uom getUom(Integer id) {
        String url = endpointUrl + "/" + Integer.toString(id);
        logger.info("getUom: " + url);

        HttpHeaders headers = new HttpHeaders();
        HttpEntity request = new HttpEntity<>(null, headers);
        final ResponseEntity<Uom> response =
                getRestTemplate().exchange(url, HttpMethod.GET, request, Uom.class);
        return response.getBody();
    }

    public Uom[] getUoms() {
        String url = endpointUrl;
        logger.info("getUoms: " + url);

        HttpHeaders headers = new HttpHeaders();
        HttpEntity request = new HttpEntity<>(null, headers);
        final ResponseEntity<Uom[]> response =
                getRestTemplate().exchange(url, HttpMethod.GET, request, Uom[].class);
        Uom[] uoms = response.getBody();
        return uoms;
    } ```

This message has been formatted automatically. You can disable this using /preferences.

magic zenith
#

Mostly all of this

#

I apologize for any inconvenience

severe badger
#

that's fine ๐Ÿ™‚ So are you sure your request is correct?

magic zenith
#

The getters have some usages for the most part
Connected on CreateProduct and UpdateProduct Controllers....

#

This is a code I have been asked for help to modify but so far this is beyond me when it's Splash view...

severe badger
#

From my POV it seems that in method "getUoms()" the "response.getBody()" return empty array. You have to find out why.

magic zenith
#

I see...

#

I should probably continue this tomorrow...

May I be able to chat with you again when I need to?

magic zenith
severe badger
#

yeah sure. Just ping me in this channel ๐Ÿ™‚

brisk brookBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

magic zenith
#

@severe badger Hey, I'm back

severe badger
#

cool ๐Ÿ™‚

magic zenith
magic zenith
#

Although I'm trying to do something that may activate the ComboBox

magic zenith
#

@severe badger You still there or is this a bad time?

magic zenith
#

I'm still working on the code

brisk brookBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

magic zenith
#

@severe badger Hey buddy, I'm actually back

severe badger
#

Hi, can you ping me in two hours? Then I should have some time for you. And sorry for yesterday. I had some urgent stuff at work...

severe badger
magic zenith
#

With your permission, of course

#

I don't wanna overload your routine atm

severe badger
magic zenith
#

You're not gonna help me?

severe badger
#

well, I saw your code and it looks good. So solve the issue with HTTP and you are good to go