user2065929
user2065929

Reputation: 1095

cannot find symbol java

I am trying to allow a user to select between two options, and then use this in aset.add(MediaSizeName.ISO_A4);

I have a page where the user selects between a3 and a4, but I am unable to pass this variable, as if I try aset.add(MediaSizeName.variable); I get the error cannot find symbol, even though it is already declared public String paperSize; and is passed when the user submits a value, basically how can I use a variable to change the .ISO bit?

Thanks

EDIT

<p:selectOneMenu value="#{printerSettings.paperSize}">
    <f:selectItem itemValue="ISO_A5" itemLabel="A5" />
    <f:selectItem itemValue="ISO_A4;" itemLabel="A4" />
    <f:selectItem itemValue="ISO_A3" itemLabel="A3" />
</p:selectOneMenu>

above is where the user selects the size

now i pass the value :

<p:commandButton type="submit"
    action="#{printInTen.countDown(printerSettings.t, printerSettings.p, printerSettings.paperSize)}"
    onclick="Thankyou()" value="Print" />

and am trying to pass the value paperSize

public String paperSize;
    public String orienation;

    public void countDown(int t, int p, String paperSize) {

 System.out.println("Now setting up attributes such as page size");
        System.out.println ("Copies " + p);
        aset.add(new Copies(p)); //having issues, will not work currently although code is fine// NOW WORKING :D
        aset.add(MediaSizeName.paperSize);// will not let me use the variable here, 
        aset.add(Sides.DUPLEX);
        aset.add(OrientationRequested.PORTRAIT);

but no matter what I try, the variable value I pass does not work in the aset.add(MediaSizeName.paperSize); I get the error cannot find symbol

Upvotes: 1

Views: 296

Answers (1)

robonerd
robonerd

Reputation: 198

if (paperSize.equals("ISO_A3")) {
    aset.add(MediaSizeName.ISO_A3);
} else if (paperSize.equals("ISO_A4")) {
    ....
}

Upvotes: 3

Related Questions